I've rerwritten this post to make it clearer as the post ranks quite highly on Google for people searching how to create email pipes on Postfix. If you follow these steps it isn't actually that hard.
Each domain has its own entry in Postfix and you put all the pipes for one script in that file. If you have a weird program that uses different pipe scripts for different email addresses on teh same domain you will need to create separate Postfix files for them.
Okay so lets use Kayako (our support system) as an example. All addresses piped into the system use the same script, nice and simple. In this example my Postfix rule and script is "pipeDomainA".
Quote:
STEP 1
Open /etc/postfix/main.cf and at line transport_maps add the option: hash:/var/spool/postfix/plesk/pipeDomainA.
So the line will be after the edit:
transport_maps = hash:/var/spool/postfix/plesk/transport,
hash:/var/spool/postfix/plesk/pipeDomainA
You must add a transport map hash for each php pipe script on each domain.
So for example if i have 4 php scripts on 4 different domains the
transport_maps will be :
transport_maps = hash:/var/spool/postfix/plesk/transport,
hash:/var/spool/postfix/plesk/pipeDomainA, hash:/var/spool/postfix/plesk/pipeDomainB, hash:/var/spool/postfix/plesk/pipeDomainC, hash:/var/spool/postfix/plesk/pipeDomainD
|
Pretty simple. One file that you have to edit and add an entry for each domain needing a pipe. Now that's done let's actually create the file that we added as a path to the Postfix file above (/var/spool/postfix/plesk/pipeDomainA).
Quote:
Step 2
Create file /var/spool/postfix/plesk/pipes with your favourite editor and add all the addresses that needed piping into your program. For example:
sales@domain.com pipeDomainA:Sent to pipe
support@domain.com pipeDomainA:Sent to pipe
accounts@domain.com pipeDomainA:Sent to pipe
management@domain.com pipeDomainA:Sent to pipe
If you remember "pipeDomainA" is my Postfix rule entered in main.cf in Step 1. These rules just connect teh email address with pipe and teh last phrase is just a description for the maillog.
|
So not hard so far. We edited the Postfix main.cf with a path to a rule script and now created the rule script itself. Exciting stuff I know.
Quote:
Step 3
Now we must hash the transport file as pipeDomainA.db as postfix likes to work with database hashed files. To hash it simply type:
postmap /var/spool/postfix/plesk/pipeDomainA.
|
Now we've created a transport_map file and its contents and hashed it.
Quote:
Step 4
Now we must tell postfix which php script will execute this transport hash file named "pipeDomainA". For this edit /etc/postfix/master.cf and add a line after plesk_saslauthd:
pipeDomainA unix - n n - - pipe flags=Fq user=apache:apache
argv=/home/httpd/vhosts/domain.com/httpdocs/your-php-pipe-script.php
${sender}
Make sure you dont enter any spaces after "${sender}" or you will have
problems, Postfix is very sensitive with its master.cf file. So a windows
editor will corrupt it for sure. I use nano, simple but effective.
|
If you have other domains with other php pipe scripts then you add an entry in master.cf for each rule.
So for multiple scripts it would be:
pipeDomainA unix - n n - - pipe flags=Fq user=apache:apache
argv=/home/httpd/vhosts/domain1.com/httpdocs/your-php-pipe-script.php
${sender}
pipeDomainB unix - n n - - pipe flags=Fq user=apache:apache
argv=/home/httpd/vhosts/domain2.com/httpdocs/your-php-pipe-script.php
${sender}
So now we've entered a rule path in main.cf, we've created the rule script with email addresses, we've hashed it and now we've edited master.cf and told Postfix which rule goes with which script. One more step...
Quote:
Step 5
To finish up stop and start Postfix.
|
If everything was set correctly you should see in /usr/loca/psa/var/log/maillog "Sent to pipe" when you do tests.