如何在 Postfix 中更改信封?

csi*_*csi 16 linux postfix wordpress amazon-ses

使用 Postfix 通过 Amazon SES 发送邮件的 Linux 服务器。从 Wordpress 发送电子邮件时,由于信封发件人地址不正确,电子邮件被拒绝。

如何配置 Postfix 以始终使用 myemail@mydomain.com 作为信封发件人地址?

我正在寻找可以配置的默认属性,而不是基于代码的解决方案。

Sør*_*org 15

将以下内容放入/etc/postfix/canonical

# Use the empty regexp to map *any* address to the desired envelope sender.
// my-fixed-envelope-sender@example.org
Run Code Online (Sandbox Code Playgroud)

将以下内容附加到/etc/postfix/main.cf

canonical_maps = regexp:/etc/postfix/canonical
canonical_classes = envelope_sender
Run Code Online (Sandbox Code Playgroud)

重新加载后缀:

postfix reload
Run Code Online (Sandbox Code Playgroud)

请注意,这只会重写信封发件人(按要求),而不是“发件人:”标头。此外,如果您在接收来自外部世界的邮件的主机上设置此项,可能会造成严重破坏。

有关更多信息,请参阅canonical(5)以及canonical_mapscanonical_classes选项的文档。


ah8*_*h83 5

您还可以从 php.ini 设置信封发送者。

如果您使用 mod_php,请将其放入您的 apache vhost 配置中:

php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fyou@example.com"
Run Code Online (Sandbox Code Playgroud)

或者在 php.ini 文件中设置值(可以是服务器范围或每个用户,具体取决于您的系统):

sendmail_path "/usr/sbin/sendmail -t -i -fyou@example.com"
Run Code Online (Sandbox Code Playgroud)

仅当发送脚本使用 php mail() 函数时这才有效。