2 个相同的 VPS(Ubuntu 18.04):Postfix - Monit 向 Google 邮件发送的警报不起作用

2 个相同的 VPS(Ubuntu 18.04):Postfix - Monit 向 Google 邮件发送的警报不起作用

让我们从头开始。我有两台相同的 VPS 服务器,两台都安装了 Ubuntu 18.04 操作系统和 Monit。我在两台服务器上的 monit(用于发送警报)配置中将邮件服务器配置为本地主机。问题是在一台服务器上一切正常,而在另一台服务器上我收到错误:NOQUEUE:拒绝:来自本地主机 [127.0.0.1] 的 RCPT: 550 5.1.1: 收件人地址被拒绝:虚拟别名表中的用户未知

我没有特别配置 Dovecot 和 Postfix,因此它们应该在默认配置下都可以工作。我比较了正常工作的 Postfix 服务器和不正常工作的 Postfix 服务器配置,它们似乎大致相同。它们如下:

工作服务器:

    # See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = sub.domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, sub.domain.com, localhost.domain.com, , localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtp_tls_security_level = may
allow_percent_hack = no

并且在此服务器上一切都正常工作,无需进行任何其他配置,只需将 localhost 作为邮件服务器放在 monit 配置中即可。

服务器不工作:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

# TLS parameters
smtpd_tls_cert_file = /etc/postfix/postfix.cert.pem
smtpd_tls_key_file = /etc/postfix/postfix.key.pem
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = sub2.domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, sub2.domain.com, localhost.domain.com, ,localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtp_tls_security_level = dane
allow_percent_hack = no
smtpd_tls_CAfile = /etc/postfix/postfix.ca.pem
smtpd_tls_security_level = may
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1

该服务器生成上述错误。

目标邮件的域名与这些服务器不同,并且邮箱位于 Google 中。检查 nslookup NX 后,似乎已正确解决:

Non-authoritative answer:
maildomain.com  mail exchanger = 5 alt2.aspmx.l.google.com.
maildomain.com  mail exchanger = 10 alt4.aspmx.l.google.com.
maildomain.com  mail exchanger = 10 alt3.aspmx.l.google.com.
maildomain.com  mail exchanger = 5 alt1.aspmx.l.google.com.
maildomain.com  mail exchanger = 1 aspmx.l.google.com.

还有一件事是,在不工作的服务器上,有配置了网站 maildomain.com 的 apache,我想这也许会使服务器混淆以发送电子邮件。也许它只在本地查找邮件地址,然后收到此错误:来自本地主机 [127.0.0.1] 的 RCPT: 550 5.1.1: 收件人地址被拒绝:虚拟别名表中的用户未知

任何关于如何让它工作以及这里可能存在哪些问题的想法都是完美的。提前谢谢您!

答案1

恐怕我还不能发表评论,所以这必须是一个答案......

看来 postfix 无法在其本地数据库中找到该用户,因此该用户似乎不是本地用户,并且该用户似乎不在 /etc/aliases 文件中。或者,您应该尝试这样做。您尚未运行 newaliases 命令。

为了获得进一步的帮助,提供更多信息将会很有用:

  • 电子邮件收件人

  • 各个 /etc/aliases 文件的内容

相关内容