Postfix使用外部smtp服务器问题

Postfix使用外部smtp服务器问题

我不确定这是否是适合我的问题的正确堆栈交换,有多个堆栈交换适合我的问题。

我已经设置了 postfix 配置以通过外部 SMTP 服务器(我的 ISP 的 SMTP,因为他们要求如此...)发送电子邮件。但是,每当我向外部电子邮件地址发送电子邮件时,它永远不会到达,我也不会收到返回的错误电子邮件(“您被阻止”电子邮件或其他任何电子邮件,如果我使用自己的 SMTP 服务器,我会收到这种电子邮件)。

这是我的邮件日志。我运行 raspbian,并且我已经替换了所有 IP 地址和域名,只是为了确定:p。我从 squirrelmail 发送了这封测试电子邮件,这就是为什么它说 localhost:

Feb  2 16:37:41 raspberrypi postfix/smtpd[1468]: connect from localhost[127.0.0.1]
Feb  2 16:37:41 raspberrypi postfix/smtpd[1468]: D7AEEC3940: client=localhost[127.0.0.1]
Feb  2 16:37:41 raspberrypi postfix/cleanup[1472]: D7AEEC3940: message-id=<[email protected]>
Feb  2 16:37:41 raspberrypi postfix/qmgr[1372]: D7AEEC3940: from=<[email protected]>, size=717, nrcpt=1 (queue active)
Feb  2 16:37:41 raspberrypi postfix/smtpd[1468]: disconnect from localhost[127.0.0.1]
Feb  2 16:37:42 raspberrypi postfix/smtp[1473]: D7AEEC3940: to=<[email protected]>, relay=smtp.myisp.com[IPmyisp]:587, delay=0.35, delays=0.07/0.01/0.19/0.07, dsn=2.6.0, status=sent (250 2.6.0  <[email protected]> Queued mail for delivery)
Feb  2 16:37:42 raspberrypi postfix/qmgr[1372]: D7AEEC3940: removed

我来自 postfix 的 main.cf 文件(再次替换了一些内容):

smtpd_banner = $myhostname ESMTP $mail_name (Raspbian)
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

# 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 = mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mydomain.com, raspberrypi, localhost.localdomain, localhost
relayhost = [smtp.myisp.com]:587 
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 = ipv4
home_mailbox = Maildir/
mailbox_command =
smtpd_recipient_restrictions =
        permit_sasl_authenticated,
        permit_mynetworks,
        reject_unauth_destination
smtpd_helo_required = yes
smtpd_helo_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
        reject_invalid_helo_hostname,
        reject_non_fqdn_helo_hostname,
        reject_unknown_helo_hostname
        check_helo_access hash:/etc/postfix/helo_access
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_tls_auth_only = yes
#################################
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_CAfile = /etc/ssl/certs/ssl-cert-snakeoil.pem

我的 /etc/postfix/sasl_passwd 的格式类似于 smtp.myisp.com:587 username:password.其中用户名和密码是我的 ISP 的用户名和密码。

我的 ISP 的 SMTP 服务器使用 TLS 和端口 587。

我不知道为什么电子邮件没有到达,如果有人知道的话,先谢谢了。

编辑:如果我使用电子邮件客户端作为我的电子邮件帐户(例如 Outlook),并且我将 ISP 的 SMTP 服务器详细信息直接输入到客户端,则电子邮件确实会到达。但这不是我希望的工作方式。

EDIT2:这是新日志:

Feb  2 19:48:12 raspberrypi postfix/smtps/smtpd[2469]: connect from myhostname[myIP]
Feb  2 19:48:13 raspberrypi postfix/smtps/smtpd[2469]: 76CCBC3ABC: client=myhostname[myIP], sasl_method=PLAIN, sasl_username=username                        
Feb  2 19:48:13 raspberrypi postfix/cleanup[2482]: 76CCBC3ABC: message-id=<[email protected]>                                                  
Feb  2 19:48:13 raspberrypi postfix/qmgr[2467]: 76CCBC3ABC: from=<[email protected]>, size=1277, nrcpt=1 (queue active)                                                                 
Feb  2 19:48:13 raspberrypi postfix/smtp[2483]: Untrusted TLS connection established to smtp.myisp.com[IPmyisp]:587: TLSv1 with cipher AES128-SHA (128/128 bits)
Feb  2 19:48:14 raspberrypi postfix/smtp[2483]: 76CCBC3ABC: to=<[email protected]>, relay=smtp.myisp.com[IPmyisp]:587, delay=0.58, delays=0.23/0.12/0.16/0.07, dsn=2$ dsn=2.6.0, status=sent (250 2.6.0  <[email protected]> Queued mail for delivery)    
Feb  2 19:48:14 raspberrypi postfix/qmgr[2467]: 76CCBC3ABC: removed

答案1

在我看来,ISP 中继服务器配置错误。它可能会立即拒绝您的邮件。

您的配置中的问题很可能是 postfix 未向 ISP 中继验证自身身份。放

smtp_sasl_auth_enable = yes

并重新加载后缀。然后再次尝试发送邮件。

来自后缀文档:

smtp_sasl_auth_enable(默认值:否)
在 Postfix SMTP 客户端中启用 SASL 身份验证。默认情况下,Postfix SMTP 客户端不使用身份验证。

相关内容