开发者

Postfix - How to process incoming emails? [closed]

开发者 https://www.devze.com 2023-02-16 13:34 出处:网络
Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

开发者_如何学Go

Closed 9 years ago.

Improve this question

Does anybody know how to process incoming emails for virtual mailboxes in postfix? I am building web application where users add new content by sending emails to application. Email address used for each user is custom (eg. 123456@myservice.com) and it is dynamically created as a Postfix virtual mailbox. User needs to be able to send email to his custom mailbox address (as12145ed@myservice.com) and i want to process each incoming email, parse it's contents and populate my database with data from email. I tried using Postfix After Queue filter but what i really wont is to process emails once they are saved in users virtual mailbox folder.


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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消