我使用 Ubuntu 22.04 LTS 和 Postfix 通过 SendGrid 发送消息。我按照此处的教程操作https://www.twilio.com/docs/sendgrid/for-developers/sending-email/postfix
我有几个 VPS,我用昵称将它们区分开来 - 这个我命名为 COCONUT。如果地址from
拼写正确,一些消息会发出,但所有系统消息都无法发送。发送时,它会尝试从发送,
我收到错误,因为 SendGrid 知道我没有来自“coconut”的权限,因此发送者的身份错误。ps -ely | mailx -s Testing [email protected]
from=<root@coconut>
/var/log/mail.log
运行时的日志条目ps -ely | mailx -s Testing [email protected]
...
Jul 19 09:28:57 coconut postfix/pickup[624347]: 290E754988: uid=0 from=<root@coconut>
Jul 19 09:28:57 coconut postfix/cleanup[624480]: 290E754988: message-id=<[email protected]>
Jul 19 09:28:57 coconut postfix/qmgr[624348]: 290E754988: from=<root@coconut>, size=17599, nrcpt=1 (queue active)
Jul 19 09:28:57 coconut postfix/smtp[624482]: 290E754988: to=<[email protected]>, relay=smtp.sendgrid.net[44.239.172.8]:587, delay=0.83, delays=0.01/0.01/0.6/0.2, dsn=5.0.0, status=bounced (host smtp.sendgrid.net[44.239.172.8] said: 550 The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements (in reply to end of DATA command))
Jul 19 09:28:57 coconut postfix/cleanup[624480]: F2DC254989: message-id=<[email protected]>
Jul 19 09:28:57 coconut postfix/bounce[624483]: 290E754988: sender non-delivery notification: F2DC254989
Jul 19 09:28:57 coconut postfix/qmgr[624348]: F2DC254989: from=<>, size=20071, nrcpt=1 (queue active)
Jul 19 09:28:57 coconut postfix/qmgr[624348]: 290E754988: removed
...
这是我的/etc/postfix/main.cf
# 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
myhostname = coconut.example.com
myorigin = example.com
mydestination = $myhostname, localhost #added to no effect
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
#header_checks = regexp:/etc/postfix/my_custom_header
inet_protocols = ipv4
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_security_level = encrypt
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587
以下是我的/etc/mailname
example.com
以下是我的/etc/hostname
coconut.example.com
关于如何修复从 root@coconut 发送的系统电子邮件,您有什么想法吗?