我已经成功地将Postfix设置为通过使用SASL的Mandrill和使用MySQL表的sender_dependent_relayhost_maps中继电子邮件,以便不同的发送者使用他们自己的Mandrill用户名和API密钥连接到Mandrill。
到目前为止这样好,但我有三个用户都使用电子邮件服务提供商,邮件信封中的发件人设置为“[email protected]”为所有三个用户,并且唯一的地方包含实际用户的电子邮件地址在From:电子邮件标题中 。
我很高兴使用From:email头的安全性(或缺乏),因为我只是将邮件发送到受严格控制的特定电子邮件地址,但我真的很感激我的build议最好根据From:标头的值指定relayhost。 有什么办法可以将信封值设置为与发件人字段相同? 或者有其他的方法来做到这一点?
基于postfix邮件列表上的这个线程: 通过sendmail(1)引入的所有邮件的不同传输 ,看起来像你的情况是可能的。 不幸的是,你不能只依靠两个表sender_dependent_relayhost_maps和smtp_sasl_password_maps 。 您需要修改master.cf 。 这个想法是使用header_checks将电子邮件路由到不同的传输。 然后在每个传输中,我们定义使用独立凭证和relayhost的smtp客户端。
首先在main.cf和它的pcre表中定义header_checks
#main.cf header_checks = pcre:/etc/postfix/header_dependent_relay #/etc/postfix/header_dependent_relay /^From:.*specialsender1\@example\.com/ smtp1:[host1.example.com] /^From:.*specialsender2\@example\.com/ smtp2:[host2.example.com] /^From:.*specialsender3\@example\.com/ smtp3:[host3.example.com]
好,现在我们在master.cf中设置smtp1 , smtp2 , smtp3传输
#master.cf smtp1 unix - - - - 10 smtp -o smtp_sasl_password_maps=hash:/etc/postfix/smtp1.relay smtp2 unix - - - - 10 smtp -o smtp_sasl_password_maps=hash:/etc/postfix/smtp2.relay smtp3 unix - - - - 10 smtp -o smtp_sasl_password_maps=hash:/etc/postfix/smtp3.relay
文件smtpX.relay有类似的内容,例如
[hostX.example.com] userX:passwordX
免责声明:
smtp_sasl_password_maps的哈希表仅作为示例。 你可以用mysql表replace它。