I need to build a web application where people can send an email to custom email addresses (like - 1week@example.com, or 2days@example.com) and the email address '1week' and '2days' is used to perform certain actions on that email.

I looked at this Postfix - How to process inbound emails?, particularly, the response - https://serverfault.com/a/247279/94544 and that is indeed a solution that will work for me.


  1. In the above mentioned solution, can I have actual inboxes, for example service@example.com which would be a real email address hosted with Google Apps? How do I specify the others to be redirected to the 'catch-all' address? Note that the email addresses - 1day, 1 week are NOT defined beforehand - there can be an email address - 9999weeks, for instance.

  2. Can the script access the email address '1week', the subject line, date/time sent, and the body?

  3. Is perl the best language for processing these emails, assuming that we scale up to handle 100s and 1000s of emails a day (or an hour)? It will need to process these emails and store them in a database.

I'm reading that the other options are of using Postfix, procmail, but I'm unsure about which would be the best, most scalable option.

  • Frands Hansen was on SF yesterday. You may consider posting the questions as comments on his answer instead of a new question.
    – TheCleaner
    May 16, 2013 at 1:58
  • Hi, sorry, I had no idea. I thought my question was different from the one he responded on, but I'll check with him if he has any thoughts on this one.
    – siliconpi
    May 16, 2013 at 3:58

2 Answers 2

  1. You can't mix Google Apps addresses with local postfix addresses. Your MX either points to G Apps or to local server.
    Maybe if G Apps allows catch-all address/alias, then that would be forwarded to usermail@subdomain.example.com, and subdomain.example.com would point to your postfix server. (where postfix alias would forward the mail's to a script).

  2. Yes

  3. Perl is a good language for processing these mails. 100/1000 mails per hour/day would depend obviously on what the script is doing. And server resources. But should be possible.


Google Apps (for Business) allows you to reroute "unknown" (and known) email addresses elsewhere.

When you are in Gmail click "Settings", "Manage This Domain" then go to "Google Apps", "Gmail", "Default Routing" you then have the ability to setup multiple rules

e.g. if you wished to send all email sent to person1@example.com to person1@example.org you can add the following rules:-

  1. Specify Envelope Recipients to Match:; Single recipient; person1@example.com
  2. Route; Envelope Receipient; / Change Envelope Receipient; Replace Receipient : person1@example.org

However it's much more powerful than that - you can add pattern matches* - e.g. [0-9]weeks@example.com could be forwarded to myautomaticprocessor@example.com or myautomaticprocessor@example.org where it would be able to see the recipient, you could also strip attachments and bypass the spam filter if you wish.

  • I'm rubbish with regexs - you'd need one that says allow characters 0-9 one or more times where the first digit is 1-9 followed by weeks@example.com

Assuming it's just days, weeks, months, and years that's not too much of a faff to setup the four rules required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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