我已经安装了fetchmail并configuration了从我的电子邮件服务器获取邮件。
poll mail.domain.com protocol imap username "[email protected]" password "password" options ssl
我的电子邮件服务器上有一个邮箱,它接收来自三个不同部门的邮件,我需要使用fetchmail对该邮件进行分类。 “To”标题字段是我可以用来过滤邮件,因为邮件正在发送到特定的部门,但我只有一个login到实际的邮件服务器。
[email protected] -> [email protected] [email protected] -> [email protected] [email protected] -> [email protected] fetchmail gets [email protected] [email protected] "To: [email protected]" -> postfix alias 1 [email protected] "To: [email protected]" -> postfix alias 2 [email protected] "To: [email protected]" -> postfix alias 3
我怎样才能做到这一点?
我build议将fetchmail和procmail结合起来。 在您的fetchmail投票声明中,添加:
mda procmail department_mail_sort.rc
然后在department_mail_sort.rc文件中,您可以定义如何分类和传递邮件。
:0 * ^[email protected] !deptartment1_mailbox@localhost :0 * ^[email protected] !deptartment2_mailbox@localhost :0: * ^[email protected] department3_local_mbox_file
Procmail有几个交付选项,所以绝对检查出procmailrc手册页。 这听起来像你正在运行一个本地mta在这种情况下! 而@localhost会在那里传递消息,但是你也可以在其他地方转发,像最后一个例子那样写入一个mbox文件,甚至使用一个pipe道来运行一个自定义程序来处理每个消息。