Postfix:基于别名的SMTP中继(来自地址)

我最近注意到,当我添加一个别名到Gmail帐户,他们问我一个远程SMTP服务器,用户名和密码。 然后,每当我尝试使用该别名发送电子邮件时,它都会被Gmail转发到提供的SMTP服务器。

有没有一种方法可以在Postfix安装上完成此设置?

为了澄清,在我的服务器上有一个虚拟用户[email protected] (别名: [email protected][email protected] ),如果他发送一封电子邮件:

  • [email protected] =>的服务器地址,服务器将默认发送;
  • [email protected]from地址=>服务器将使用smtp.xpto.com中继电子邮件(具有正确的凭证);
  • 使用from [email protected] =>的服务器地址,服务器将使用smtp.corpx.com中继邮件(具有适当的凭据);

理想情况下,如果我可以有一个包含外部SMTP服务器域,端口,用户名和密码的外部语言(针对每个虚拟用户)的MySQL表。 =>这样我就可以设置一个小的网页界面,这样我的用户就可以拥有所有的外部声音了。

谢谢。

我想你可以通过调整sender_dependent_default_transport_mapssender_dependent_relayhost_maps Postfix参数来实现。 例如:

 # /etc/postfix/main.cf sender_dependent_default_transport_maps = hash:/etc/postfix/sender_maps.cf smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sender_credentials.cf smtp_sasl_tls_security_options = noanonymous smtp_sender_dependent_authentication = yes smtp_tls_security_level = may # /etc/postfix/sender_maps.cf [email protected] smtp:[smtp.xpto.com]:587 [email protected] smtp:[smtp.corpx.com] # /etc/postfix/sender_credentials.cf [email protected] xptouser:xptopassword [email protected] corpxuser:corpxpassword 

这个例子使用静态哈希表。 如果您的Postfix安装支持mysql_table(5) ,则可以使用MySQL查询。

我现在无法testing这个解决scheme。 我希望它的作品。