由于IP /域名(我的服务器和域名最近)的问题,我不得不使用Amazon SES作为SMTP中继,以便我的邮件不能被标记为垃圾邮件。
我用亚马逊的设置工作正常,但我不能使用亚马逊SMTP做邮件转发,因为必须validationFROM标头的地址。
我决定做的只是通过亚马逊发送从我的服务器直接发送的邮件,并使用我自己的SMTP转发的东西。 (因为邮件是由其他名誉良好的服务器签名的,即使邮件是由我的服务器发送的,它也不会被标记为垃圾邮件)
为此,我使用了以下设置:
relayhost = sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_maps sender_canonical_maps = regexp:/etc/postfix/sender_canonical sender_canonical_classes = envelope_sender smtpd_data_restrictions = check_sender_access pcre:/etc/postfix/sender_access
relayhost_maps:
[email protected] [email-smtp.eu-west-1.amazonaws.com]:25 @domain2.tld [email-smtp.eu-west-1.amazonaws.com]:25 @domain3.tld [email-smtp.eu-west-1.amazonaws.com]:25 @domain4.tld [email-smtp.eu-west-1.amazonaws.com]:25 @domain5.tld [email-smtp.eu-west-1.amazonaws.com]:25
sender_canonical:
/.*/ [email protected]
sender_access:
/(.*)/ prepend X-Envelope-From: <$1>
我通过亚马逊传递我的域名的所有邮件,除了将用于转发地址[email protected]的domain1。 我需要重写信封地址,才能转发邮件。
我的问题是,我想重写信封地址只来自我的服务器外部的邮件,我转发到外部电子邮件。 所有从我的用户webmails直接发送的邮件必须通过亚马逊。
经过更多的研究,似乎要做我想做的事情就是在sender_canonical文件中使用regexp。
我试图写下面的expression式,但似乎有什么问题。
/^(([email protected])([email protected])([email protected])([email protected])([email protected]).)*$/gm [email protected]
编辑:我终于find正确的方式来编写expression式:
!/@domain1.tld|@domain2.tld|@domain3.tld|@domain4.tld|@domain5.tld/ [email protected]