Setting Return-Path in PHP

We have a system that needs to send automated emails. But we were having a problems where we were not getting bounce emails from invalid email addresses.

After half a day of digging it turns out the problem was that the Return-Path header was being set to the user that the web server runs as. Which was a non-existent email address.

To set the Return-Path in PHP on a unix environment use:
mail('nobody@example.com', 'the subject', 'the message', null, '-fwebmaster@example.com');

In windows envioronment use:
ini_set('sendmail_from', 'webmaster@example.com);

For more information see: http://www.php.net/manual/en/function.mail.php

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: