AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1162781
Accepted
wruckie
wruckie
Asked: 2024-07-19 23:49:09 +0800 CST2024-07-19 23:49:09 +0800 CST 2024-07-19 23:49:09 +0800 CST

如何修复通过 Postfix 发送的系统电子邮件中的默认发件人地址

  • 772

我使用 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 发送的系统电子邮件,您有什么想法吗?

ubuntu
  • 1 1 个回答
  • 66 Views

1 个回答

  • Voted
  1. Best Answer
    Esa Jokinen
    2024-07-20T04:00:41+08:002024-07-20T04:00:41+08:00

    您可以将 Postfixcanonical_maps与规范(5)地图一起使用。

    1. 添加设置canonical_maps = hash:/etc/postfix/canonical

    2. 创建/etc/postfix/canonical包含,例如,

      @coconut @example.com
      
    3. 由于查找表类型是 Berkeley DB ( hash),
      因此在对文件进行任何修改后都需要使用它:

      sudo postmap /etc/postfix/canonical
      
    4. 重新加载 Postfix。

      sudo systemctl reload postfix
      

    该系统现在应该重写root@coconut为规范[email protected]。

    • 1

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • ubuntu apt-get upgrade - 如何在 shell 中单击确定?

  • VirtualBox 上 Ubuntu 的访客优化技巧 [关闭]

  • 外部硬盘上的 virtualbox 虚拟硬盘驱动器(Vista 主机上的 ubuntu 客户机)

  • 如何在 Ubuntu 上挂载 LVM 分区?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve