如何强制 postfix 使用 smtp 中继

如何强制 postfix 使用 smtp 中继

当我执行以下行时,postfix 使用我的 sendgrid 中继服务器

echo "Subject: sendmail test" | sendmail -v [email protected]

但是当我通过 PHP 脚本执行 sendmail 函数时,它不会将其发送到中继服务器。看起来它想在本地分发它

关于如何强制 postfix 使用 smtp 中继选项的任何想法

  • 更新

看起来 postfix 在 STARTTLS 上超时了,我添加了下面的日志。这可能是由于我的 LetsEncrypt 证书造成的吗?

postfix/smtpd[29268]: > localhost[::1]: 250-www.example.com
postfix/smtpd[29268]: > localhost[::1]: 250-PIPELINING
postfix/smtpd[29268]: > localhost[::1]: 250-SIZE 10240000
postfix/smtpd[29268]: > localhost[::1]: 250-VRFY
postfix/smtpd[29268]: > localhost[::1]: 250-ETRN
postfix/smtpd[29268]: > localhost[::1]: 250-STARTTLS
postfix/cleanup[29279]: 8E2B520B98: message-id=<[email protected]>
postfix/smtpd[29268]: smtp_get: EOF

后配置-n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
header_size_limit = 4096000
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = $myhostname, localhost.$mydomain, localhost
mydomain = example.com
myhostname = www.example.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = smtp.sendgrid.net:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:apikey:BLBAABLAABLAA
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_security_level = encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname E
SMTP $mail_name (Debian/GNU)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes

当我编写 python 脚本时,它似乎运行良好,但使用 PHP swiftmailer 时,它似乎失败并返回 EOF

=============== 更新

继电器似乎工作正常,但现在我们收到此错误

Swift_IoException [ 0 ]: Connection to localhost:25 Timed Out

我可以使用 sendmail 发送邮件,但是当 SwiftMailer 使用 sendmail 时,它会收到前面提到的错误

答案1

我设法解决了这个问题。原来是客户发送的邮件中嵌入了未经授权的图片。我删除了嵌入的图片,现在一切正常!

我觉得很奇怪,在 postfix 的详细日志中什么都没有显示

相关内容