Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

Consider the following scenario:

1) Somebody ( sends an e-mail to address-<id> where <id> is an arbitrary number. address-<id> is not an existing account on

2) will send back an auto-reply to

3) In the body of the auto-reply message <id> will be used.

How can I implement this using postfix's pipe on

share|improve this question
This is a very Bad Idea, since spammers will try out addresses on your server often using valid sender addresses. With your scheme, these accounts will get flooded, which might get your server blacklisted. – Floyd Sep 8 '12 at 5:45
up vote 2 down vote accepted

There is a lot of solutions out there that will enable you to capture mail in various languages.

I am most familiar with doing this in cpanel, but you seem to be familiar with setting it up manually so the only piece you are missing is the code?

If so take a look at this article

There are more in depth libraries that will separate the body and recipient/sender emails so you can have all these parts in a clean fashion.(Which on also given in the example)

After you get the senders email of a non-existent email you can use PHP's mail function to let them know no mail can go to the recipient because they don't exist.

If you want to validate an email address exists here is a working example, but it uses SMTP.. and PHP not sure if this is what your going for.

Overall I think with these examples you can get a working code sample with some tweaking and testing.

Hope this helps. Let me know if you need more help.


To do this in cpanel go to "Default Address" then go to "Advanced Options" then go to "Pipe to Program" then you want to put in the path to the PHP or language script/program you want to use.

share|improve this answer
I can use cpanel as well. Could you please explain how to do this using cpanel? – EmreA Sep 8 '12 at 3:11

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.