在网上找了好久,终于让我找到与此相关的设置。发到此出大家一起再研究一下。
postfix可以针对特定的收件人地址进行修改该邮件的subject
思路:
1.建立2个smtpd,第一个监听0.0.0.0:25,第二个监听127.0.0.1:10026
2.0.0.0.0:25接收邮件,检测收件人地址,如果是特定地址,则把这个邮件forward到127.0.0.1:10026做header_checks
例如:收件人地址包含special.com的邮件,都在主题前面加个[haha]
做法:
1.设置0.0.0.0:25做check_recipient_access
[root@postfix]# more /etc/postfix/main.cf
smtpd_recipient_restrictions =
permit_mynetworks,
check_recipient_access pcre:/etc/postfix/recipient_access.txt,
##让0.0.0.0:25做check_recipient_access
permit_sasl_authenticated,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
。。。。。。
recipient_access.txt 的内容
[root@postfix]# more recipient_access.txt
/special.com/ FILTER smtp:[127.0.0.1]:10026
##这个作用就是把收件人为special.com的邮件到forward到127.0.0.1:10026
2.在/etc/postfix/master.cf 加入以下2段
mycleanup unix n - - - 0 cleanup
-o header_checks=pcre:/etc/postfix/header_checks.txt
##上面这段自定义一个cleanup,因为header_checks是由cleanup来实现的
127.0.0.1:10026 inet n - n - - smtpd
-o cleanup_service_name=mycleanup
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o receive_override_options=no_unknown_recipient_checks
##上面这段是新建一个smtpd,让它监听127.0.0.1:10026
-o cleanup_service_name=mycleanup 这个参数告诉127.0.0.1:10026
让它使用我们自定义的mycleanup
header_checks.txt的内容
[root@postfix]# more header_checks.txt
/Subject:(.*)/ REPLACE Subject:[haha] $1
3.然后重启 postfix