我已经配置了与此类似的 postfix:使用 sendgrid 发送电子邮件时出现“收件人地址被拒绝”
$ /etc/postfix/main.cf
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:username:password
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net:587]
但我一直收到这样的错误:
Feb 3 22:57:29 vsempprdapp11 postfix/error[24019]: 327A4441481: to=<[email protected]>, relay=none, delay=193633, delays=193632/1/0/0.01, dsn=4.3.0, status=deferred (unknown mail transport error)
netstat 显示我正在监听端口 25
/var/www/app: netstat -an | grep :25
tcp 0 0 0.0.0.0:25 0.0.0.0:*
LISTEN
tcp6 0 0 :::25 :::*
LISTEN
udp6 0 0 fe80::250:56ff:fe96:123 :::*
我的后置配置
另一件有趣的事情是,如果我将我的更改main.cf
为关注,它适用于非域名电子邮件 ID(@bratgroup.com 以外的电子邮件地址,如 @gmail.com、@hotmail.com 电子邮件会被发送)。对于 @bratgroup.com mail.log 说connection timed out
# 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 = mybrat.bratgroup.com
mydomain = mybrat.bratgroup.com
myhostname = mybrat.bratgroup.com
mydestination = localhost.$mydomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
message_size_limit = 27852800
append_dot_mydomain = no
biff = no
readme_directory = no
#delay_warning_time = 4h
# TLS parameters
smtpd_use_tls=yes
smtpd_tls_cert_file=/etc/apache2/ssl/mybrat.bratgroup.com/site.crt
smtpd_tls_key_file=/etc/apache2/ssl/mybrat.bratgroup.com/site.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# opportunistic encryption, as a client
smtp_tls_security_level = may
bounce_template_file = /etc/postfix/bounce.cf
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
relayhost =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
virtual_mailbox_domains = mybrat.bratgroup.com
virtual_mailbox_maps =
答案1
我的上述 SMTP 设置有语法错误:
relayhost = [smtp.sendgrid.net:587]
本来应该
relayhost = [smtp.sendgrid.net]:587
參考文獻:https://sendgrid.com/docs/Integrate/Mail_Servers/postfix.html