我正在尝试configurationpostfix将来自不同域的传入邮件放到各自的catchall邮箱。
用例如下:
例如下面的传入邮件:
From: [email protected] To: [email protected]
应该放置在本地虚拟邮箱中:
/customer1.com
To域永远是一样的。 本地邮箱都被命名为可能的传入来自域。
有没有可能使用virtual_mailbox_maps或类似的目的?
更新:
我在/etc/postfix/virtual_alias_maps创build了以下条目:
@myservice.com catchall
把所有的邮件都指向邮箱“catchall”。
在这个邮箱中,我创build了一个Sieve脚本/var/mail/vhosts/myservice.com/catchall/.dovecot.sieve :
require ["variables"]; # pick any ("*") domain in From or Sender header if address :matches :domain ["From", "Sender"] "*" { # the variable ${1} contains the domain name redirect "${1}"; }
此Sieve脚本将所有邮件redirect到等于发件人域的邮箱(例如customer1.com)。
要拒绝未知(不在数据库中)域中的所有邮件,请在/etc/postfix/main.cf使用smtpd_sender_restrictions:
smtpd_sender_restrictions = permit_mynetworks, pgsql:/etc/postfix/pgsql_check_sender_access.cf
/etc/postfix/pgsql_check_sender_access.cf :
user = dbuser password = dbpass dbname = customers query = select case count(*) when 0 then 'REJECT' else 'OK' end from servers where user_domain='%d'; hosts = 127.0.0.1:5432
这不是MTA的工作。 在MUA(你的客户端程序)中做这个更好。
如果你真的想在服务器端做到这一点,select一些像dovecot(它是sieve兼容)或maildrop(拥有自己的专有过滤解决scheme)的邮件过滤程序。 (procmail也可用,但我不会推荐那个)。
有一个Maildropconfigurationhowto http://www.postfix.org/MAILDROP_README.html如何设置filter: http : //www.courier-mta.org/maildropex.html