Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I have configured postfix for my kk.com domain successfully. Now I want to add function as described in the following example:

If someone mails me at admin@kk.com, one php script will fetch information of sender email inside mail details and also (defined in php script) add and store in some mysql database and automatically forward this msg to another postfix account like rooot@kk.com . I have little information that I need to config main.cf file in postfix and set some called aliases. I have configured postfix first time and I don't have deep knowledge of it..

What is this technique called ?

How can I make this possible?

share|improve this question

The simplest way to do something like that is to set up an alias that forwards a copy of the target user's mail to a program that munges it at leisure.

Be careful, at least here in Chile it is illegal to manipulate other's electronic mail in any way. Even if they agree (no, I didn't write the laws).

share|improve this answer
A common arrangement is to do this from .procmailrc. Procmail mainly adds a bit of a safety net and the ability to call arbitrary external programs just by editing a user file, so you don't have to much with the system's settings. – tripleee Jan 24 '13 at 19:48

This can be done by specifying content filter in master.cf, see this: http://blog.thecodingmachine.com/content/triggering-php-script-when-your-postfix-server-receives-mail

share|improve this answer
Please do not post an answer that consists essentially of a link. Include the important points in your answer; leave the link for extra information or as a reference. – Gilles Jan 23 '13 at 22:21

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.