Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am building web application where users add new content by sending emails to application. Email address used for each user is custom (eg. and it is dynamically created as a Postfix virtual mailbox.

User needs to be able to send email to his custom mailbox address ( 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 want is to process emails once they are saved in user's virtual mailbox folder.

share|improve this question

I would take another approach to this.

Instead of creating individual mailboxes, I would create one catchall address and then via /etc/aliases send that to a script in which I would do all my parsing and archiving. There is no reason to use mailboxes when you are not going to store e-mail in them, it's a huge overhead.

In /etc/aliases you could make this entry

usermail: "|/path/to/" 

and then all e-mail would be sent directly to and you can handle it in there.

share|improve this answer

I would poll the mailboxes using POP3/IMAP, download the messages and process them (rather than try to integrate something into the Postfix stack). This will also give you a level of fault-tolerance if your parsing system breaks or needs to be taken offline for a window of time.

share|improve this answer

There is a program called procmail (an LDA) that will do almost exactly what you're looking for.

share|improve this answer

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.

(Note: I also posted this on Stackoverflow, where the poster asked the same question)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.