如何让所有 Postfix 电子邮件都有一个发件人电子邮件地址

如何让所有 Postfix 电子邮件都有一个发件人电子邮件地址

我正在使用 Amazon SES,它在 postfix master.cf 中看起来像这样......

aws-email  unix  -       n       n       -       -       pipe
  flags=R user=dhiller argv=/usr/bin/perl -I/opt/amazon/ses /opt/amazon/ses/ses-
send-email.pl -r --verbose -k /opt/amazon/ses/aws_credentials.conf -e https://em
ail.us-east-1.amazonaws.com -f [email protected] ${recipient}

我希望[电子邮件保护]将覆盖发件人地址,但从 wordpress 发送时似乎不起作用,但如果我使用命令行发送,它就会起作用。

有人知道如何配置 postfix 来更改收到的所有电子邮件的发件人地址,然后再调用上面的 amazon perl 脚本,以便我的发件人地址正确吗?

谢谢,Dean

答案1

我相信解决方案是通过canonical(5)映射工具,它描述地址清理使用守护进程执行的操作cleanup(8)

   The optional canonical(5) table specifies an address mapping
   for local and non-local addresses. The mapping is used by the
   cleanup(8) daemon, before mail is stored into the queue.  The
   address mapping is recursive.
   ...
   Typically, one would use the canonical(5) table to replace
   login names by Firstname.Lastname, or to clean up addresses
   produced by legacy mail systems.

此地址清理可对本地提交()和远程提交(通过 SMTP)执行/usr/sbin/sendmail- 如果 Wordpress 通过 SMTP 发送邮件,您可能需要将您的 Wordpress 主机名添加到local_header_rewrite_clients

您向命令提供纯文本表(通常是/etc/postfix/canonicalpostmap(1)以构建索引数据库。如果From:来自 Wordpress 的 始终相同([email protected]例如),则条目将是:

[email protected] [email protected]

如果From:来自 Wordpress 的内容发生变化,但域名始终相同,则可以使用:

@alvazan.com [email protected]

如果From:真的可以是任何东西,并且你总是想[email protected]From:标题中使用,那么你可以使用正则表达式支持。我对此有点怀疑,但这是一个选择:

/./ [email protected]

您应该将canonical_classes变量设置为envelope_sender, header_sender。(默认情况下,它还包括envelope_recipientheader_recipient;保留它可能不会有什么坏处,但(尤其是使用贪婪的正则表达式选项)可能会造成灾难性的后果。这取决于如何使用此特定服务器。)

我建议在深夜进行测试,并确保在进行所有更改后测试进出系统的邮件。并且不要忘记将您的配置置于某种源代码控制之下。(但您知道这一切。)

相关内容