从本地网络进行 Postfix 中继

从本地网络进行 Postfix 中继

我在使用 Postfix 中继从本地网络发送邮件时遇到问题。我收到以下错误

    Jul  9 23:00:46 ext1 postfix/smtpd[2301]: warning: inet_protocols: disabling IPv6    name/address support: Protocol not supported
    Jul  9 23:00:46 ext1 postfix/smtpd[2301]: warning: TLS has been selected, but TLS support is not compiled in
    Jul  9 23:00:46 ext1 postfix/smtpd[2301]: connect from unknown[192.168.0.173]
    Jul  9 23:00:46 ext1 postfix/smtpd[2301]: NOQUEUE: reject: RCPT from unknown[192.168.0.173]: 554 5.7.1 <unknown[192.168.0.173]>: Client host rejected: Access denied; from=<user@exxx> to=<xxx@yyy> proto=ESMTP helo=<[192.168.0.173]>
    Jul  9 23:00:46 ext1 postfix/smtpd[2301]: disconnect from unknown[192.168.0.173]
    Jul  9 23:00:46 ext1 dovecot: pop3-login: Login: user=<user@xxx>, method=PLAIN, rip=192.168.0.173, lip=192.168.0.47
    Jul  9 23:00:46 ext1 dovecot: POP3(user@xxx): Disconnected: Logged out top=0/0, retr=0/0,     del=0/0, size=0

我的main.cf

    queue_directory = /var/spool/postfix
command_directory = /usr/local/sbin
daemon_directory = /usr/local/libexec/postfix
data_directory = /var/db/postfix
mail_owner = postfix
myhostname = localhost
mydomain = localdomain
myorigin = $myhostname
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
local_recipient_maps = unix:passwd.byname $alias_maps
unknown_local_recipient_reject_code = 550
mynetworks_style = host
mynetworks = 192.168.0.0/16, 127.0.0.0/8
alias_maps = hash:/etc/mail/aliases
alias_database = hash:/etc/mail/aliases
smtpd_banner = $myhostname ESMTP $mail_name
debug_peer_level = 2
debugger_command =
    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
    ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/local/sbin/sendmail
newaliases_path = /usr/local/bin/newaliases
mailq_path = /usr/local/bin/mailq
setgid_group = maildrop
html_directory = /usr/local/share/doc/postfix
manpage_directory = /usr/local/man
sample_directory = /usr/local/etc/postfix
readme_directory = /usr/local/share/doc/postfix
virtual_mailbox_base = /usr/mail/
virtual_alias_maps = mysql:/usr/local/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/usr/local/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/usr/local/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid             = 65534
virtual_uid_maps                = static:65534
virtual_gid_maps                = static:65534
virtual_transport               = dovecot
dovecot_destination_recipient_limit = 1
smtpd_sasl_auth_enable = yes
smtpd_sasl_exceptions_networks = $mynetworks
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination

您能帮忙找出问题所在吗?谢谢

答案1

首先,您应该将“localhost”和“localdomain”更改为您的实际主机名和域。其次,对于受信任的主机,您有两个不同的参数 - 您有

mynetworks_style = host
mynetworks = 192.168.0.0/16, 127.0.0.0/8

第一个命令表示只信任此主机。当您在下一行指定网络时,没有理由选择该命令,这可能是导致您出现问题的原因。

答案2

我通常在 /etc/postfix 目录内的 mynetworks 文件中定义允许的网络。

然后加

mynetworks = $config_directory/mynetworks

在 main.cf 里面。

保存并重启postfix

答案3

当我尝试使用终端发送电子邮件时遇到了这个中继问题:

nc mail.mydomainname.nl 25
220 mail.mydomainname.nl ESMTP Postfix (Ubuntu)
EHLO mydomainname.nl
250-mail.mydomainname.nl
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
MAIL FROM: [email protected]
250 2.1.0 Ok
RCPT TO: [email protected]
554 5.7.1 <[email protected]>: Relay access denied

通过修改 /etc/postfix/main.cf 并将我的邮件服务器的外部 IP 地址添加到 mynetworks 行,解决了 postfix 中继错误 554 5.7.1(以及 postfix 错误 451 4.3.0:临时查找失败):

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 XXX.XXX.XXX.XXX

XXX.XXX.XXX.XXX当您使用 whatismyip 测试时获得的 ip 地址在哪里。

相关内容