OpenSource For You

Redirect your bounces to a PHP bouncehand­ling script

-

We now have a VERP address being generated on every sent email, and it will have all the necessary informatio­n we need securely embedded in it. The remaining part of our task is to capture and validate the bounces, which would require redirectin­g the bounces to a processing PHP script.

By default, every bounce message will reach all the way back till the MTA that sent it, say mx.example.com, as its return-path gets set to mails@example.com, with or without VERP. The advantage of using VERP is that we will have the encoded failing address, too, somewhere in the bounce. To get that out from the bounce, we can HTTP POST the email via curl to the bounce processing script, say localhost/handleBoun­ce.php using an exim pipe transport, as follows: $sudo nano /etc/exim4/exim4.conf # suppose you have a recieve_all router that will accept all the emails to your domain. # this can be the system_alias router too recieve_all: driver = accept transport = pipe_transport # Edit the pipe_transport pipe_transport: driver = pipe command = /usr/bin/curl http://localhost/handleBoun­ce..php --data-urlencode "email@-" group = nogroup return_path_add # adds Return-Path header for incoming mail. delivery_date_add # adds the bounce timestamp envelope_to_add # copies the return

path to the To: header of bounce

The email can be made use of in the handleBoun­ce.php by using a simple POST request.

$email = $_POST[ ‘email’ ];

Newspapers in English

Newspapers from India