First possibility: You can set a custom mailbox_command in Postfix. For each email Postfix receives, it will call the mailbox_command defined in the configuration file and provide the email as plain text on stdin. That way, you can decide how you want to process each email. You will have to parse the headers of the email yourself though. You can take a look at the Postfix documentation for more of an idea on how to make this work. Additional applications like procmail can also act as a mailbox_command and help you with processing the incoming mails.
Second possibility: Use Dovecot to store emails. You don't need to enable the POP/IMAP modules of Dovecot. However, Dovecot comes with the fantastic doveadm utility which allows you to query mailboxes and read from them. With doveadm, you can automatically select new emails, emails from last week, read the whole email, just part of it, delete old messages, and so forth. It's a powerful utility, I use it in various scripts to purge old emails or provide learn-as-spam folders for users. Take a look at the documentation in the wiki.
发布评论
评论(1)
我可以想到两种可能的解决方案:
第一种可能性:您可以在 Postfix 中设置自定义
mailbox_command
。对于 Postfix 收到的每封电子邮件,它将调用配置文件中定义的mailbox_command
并在stdin
上以纯文本形式提供电子邮件。这样,您就可以决定如何处理每封电子邮件。不过,您必须自己解析电子邮件的标头。您可以查看 Postfix 文档,了解有关如何使这项工作发挥作用。procmail
等其他应用程序也可以充当mailbox_command
并帮助您处理传入邮件。第二种可能性:使用 Dovecot 存储电子邮件。您不需要启用 Dovecot 的 POP/IMAP 模块。然而,Dovecot 附带了出色的
doveadm
实用程序,它允许您查询邮箱并从中读取内容。使用doveadm
,您可以自动选择新电子邮件、上周的电子邮件、阅读整封电子邮件、仅部分电子邮件、删除旧邮件等等。它是一个功能强大的实用程序,我在各种脚本中使用它来清除旧电子邮件或为用户提供学习垃圾邮件文件夹。查看 wiki 中的文档。I can think of two possible solutions to this:
First possibility: You can set a custom
mailbox_command
in Postfix. For each email Postfix receives, it will call themailbox_command
defined in the configuration file and provide the email as plain text onstdin
. That way, you can decide how you want to process each email. You will have to parse the headers of the email yourself though. You can take a look at the Postfix documentation for more of an idea on how to make this work. Additional applications likeprocmail
can also act as amailbox_command
and help you with processing the incoming mails.Second possibility: Use Dovecot to store emails. You don't need to enable the POP/IMAP modules of Dovecot. However, Dovecot comes with the fantastic
doveadm
utility which allows you to query mailboxes and read from them. Withdoveadm
, you can automatically select new emails, emails from last week, read the whole email, just part of it, delete old messages, and so forth. It's a powerful utility, I use it in various scripts to purge old emails or providelearn-as-spam
folders for users. Take a look at the documentation in the wiki.