根据不同的条件设置content filter

根据不同的条件设置content filter
假定content filter为amavis,监听在127.0.0.1:10024
1.来自mailfrom@mailfrom.com的邮件都送到amavis进行检查:
(1)在/etc/postfix/main.cf中设置:
smtpd_sender_restrictions = check_sender_access  regexp:/etc/postfix/sender_access
(2)建立/etc/postfix/sender_access,内容如下:
/mailfrom@mailfrom.com/      FILTER  smtp:[127.0.0.1]:10024
(3)重起
postmap /etc/postfix/sender_access
/etc/init.d/postfix  reload
 
2.发送给to@to.com的邮件都送到amavis进行检查:
(1)在/etc/postfix/main.cf中设置:
smtpd_recipient_restrictions = check_recipient_access  regexp:/etc/postfix/recipient_access
(2)建立/etc/postfix/recipient_access,内容如下:
/to@to.com/      FILTER  smtp:[127.0.0.1]:10024
(3)重起
postmap /etc/postfix/recipient_access
/etc/init.d/postfix  reload
 
3.“只”对发送给自己服务器上virtual users的邮件进行content filter
(1)在/etc/postfix/main.cf中设置:
virtual_transport = smtp:[127.0.0.1]:10024
(2)设置amavis扫描完邮件后,把邮件丢给127.0.0.1:10025的smtpd
(3)在master.cf中再增加一个smtpd
127.0.0.1:10025 inet n - y - - smtpd
      -o local_recipient_maps=
      -o relay_recipient_maps=
      -o smtpd_restriction_classes=
      -o smtpd_client_restrictions=
      -o smtpd_helo_restrictions=
      -o smtpd_sender_restrictions=check_sender_access,regexp:/etc/postfix/access
## 请注意,上面的这句check_sender_access跟regexp:/etc/postfix/access之间
## 一定要有逗号,因为master.cf的参数间是不能有“空格”的   
      -o smtpd_recipient_restrictions=permit_mynetworks,reject
      -o mynetworks=127.0.0.0/8
      -o strict_rfc821_envelopes=yes
      -o smtpd_error_sleep_time=0
      -o smtpd_soft_error_limit=1001
      -o smtpd_hard_error_limit=1000
(4)在/etc/postfix/access文件中加入
 /.*/     FILTER maildrop:
 ##上面的意思就是127.0.0.1:10025所接受到的所有邮件都使用maildrop来投递
 ##/.*/     FILTER maildrop:  这句后面的那个“冒号”不能少
 postmap /etc/postfix/access
 (5)重起
/etc/init.d/postfix  reload

分享到