Setting up postfix for redirecting bounced emails is actually very easy, but I have to say that the documentation is total crap in that regard. Also most of the posts I found about it are blatantly wrong! They often speak of using VERP, which is a cheap way of knowing to whom the email was sent. But that means you need to have hundred of emails and it causes problems with greylists. Also some mail systems do not correctly support VERP.
First you want to make sure that the snapbounce package is installed. You may check for the availability with:
snapbounce --version
The real way to fix this problem is to setup your postfix MTA correctly. That means setting it the following way:
notify_classes = bounce, ... bounce_notice_recipient = bounces@snapwebsites.org transport_maps = hash:/etc/postfix/transport.maps
The notify_classes needs to at least include bounce.
The bounce_notice_recipient is set to any email address that is to be used whenever an email gets bounced. It also appears in the transport.maps file as shown below.
The transport_maps links the bounce_notice_recipient to a script defined in the master.cf file.
bounces@snapwebsites.org snapbounce:
Here we find the email defined earlier with bounce_notice_recipient in /etc/postfix/main.cf.
The email is followed by the name of the service, snapbounce, to start when the email is matched. You may use any name that does not clash with an existing postfix name. To see the existing names, you can edit the next file: /etc/postfix/master.cf.
Since we reference the file with hash, we have to compile it. This is done with:
postmap /etc/postfix/transport.maps
I suggest you leave a comment in the file so you do not forget to re-run postmap if you edit the file again:
# After changes to this file, run:
# postmap /etc/postfix/transport.maps
bounces@snapwebsites.org snapbounce:
# service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) snapbounce unix - n n - - pipe flags=FRq user=bounce argv=/home/bounce/bin/snapbounce --sender ${sender} --recipient ${recipient}
Here we see that the name of the service, snapbounce, is the same name we used in the /etc/postfix/transport.maps file.
Once all three files are properly setup and the transport.maps compiled, you may restart the postfix service to make sure all the changes are taken in account. Now test sending invalid emails and see that bounced emails appear in the database in the emails table under the bounced row.
Snap! Websites
An Open Source CMS System in C++