基于SMTPvalidation重写目标地址

为了开发的目的,我们要build立一个邮件服务器(postfix),它将通过一个特定的SMTP帐户发送的所有邮件指向同一个帐户。

编辑 :邮件将不再被发送到原来的地址。

所以我们会为不同的项目创build不同的账号,一个项目的所有邮件都会转到一个邮箱。

我们目前使用此解决scheme: 重写所有(除一个收件人外)电子邮件的收件人

但是,我们如何根据SMTP AUTH帐户来适应不同的目标地址呢?

这里有两个选项:

1.在Postfix中使用sender_bcc_maps选项。

sender_bcc_maps(默认:空)

可选的密件抄送(密码抄送)地址查询表,由发件人地址索引。 当邮件从Postfix外部进入时,BCC地址(不支持多个结果)被添加。

您需要在/etc/postfix/my.cnf添加以下内容:

 sender_bcc_maps = hash:/etc/postfix/bcc_maps 

并在/etc/postfix/bcc_maps文件中添加所需的映射:

 [email protected] [email protected] [email protected] [email protected] 

然后运行:

 postmap /etc/postfix/bcc_maps 

并重新启动Postfix。

  1. 基于发件人的redirect

在main.cf中:

smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access

并在sender_access文件中:

 from_address@domain redirect new_to_address@anotherdomain. 

然后postmap /etc/postfix/sender_access并重新启动postfix

这不是基于SMTPvalidation的答案但提供了一个基于您的需求的解决scheme。

我用这个规范的地图,我设置了一个新的VPS(centos / ubunbtu无论),然后设置我的'dev'系统到这个盒子的智能主机(在networking内,192.168.0一个例子)你可以用wp-smtp或其他人,我们使用interworx所以一个聪明的主机效果最好。

 [root@mx ~]# cat /etc/postfix/main.conf recipient_canonical_classes = envelope_recipient recipient_canonical_maps = regexp:/etc/postfix/recipient_canonical_map mynetworks = 192.168.0.0/24 header_checks = regexp:/etc/postfix/header_checks relayhost = mailserver.example.com [root@mx ~]# cat /etc/postfix/header_check /^Subject: (.*?)$/ REPLACE Subject: [Dev] $1 [root@mx ~]# cat /etc/postfix/recipient_canonical_map /./ [email protected] 

* regexp所以不需要postmap文件。

由于这是一个开发环境,从个人经验来看,我不会build议操纵你的产品来适应开发,而是build立像这样的系统来连接这些系统。

http://www.postfix.org/postconf.5.html#recipient_canonical_maps