You may want to specify a return-path for your website generated mail. This is the address to which rejected mail will be returned. This is very different from a return address. You can specify the return-path by using the -f parameter in the mail() function or specifying the -f parameter as a default in a php.ini file.
You can put the -f parameter in the mail() function, as follows :
Code: Select all
mail($toEmailAddress,$subject,$message,$headers,"-f$returnAddress");
Is is a fifth parameter, and note there is no space between the -f and the email address.
You can combine the example above with these two lines (put them first) to cover all the bases (Return Path, Reply To, and From).
Code: Select all
$headers = "From: <$returnAddress>\n";
$headers .= "Reply-To: <$returnAddress>\n";
You can specify a default return-path in your php.ini file using this line:
Ensure the sendmail path is correct for your host, and again note there is no space between the -f and the email address.