Problem with php mail function bouncing emails back to postmaster.

A server I manage hosts around 200 sites each owned by different webmasters.  A number of these have form to mail style scripts.  A small problem is that the mailserver appears to be receiving emails from these scripts as anonymous@hostname.co.uk.   When an invalid email address is given on the form these bounces are going back to postmaster@hostname.co.uk.

I was asked to fix the scripts to ensure that the bounces go back to the $from field.  Here is a quick fix.

Append -f $to to the mail() line…  For example change

This

mail($to, $subject, $message, $headers);

To this

mail($to, $subject, $message, $headers, '-f $bounceto');

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.