Home Email My Account ☎ 480-624-2500

How can I get emails that bounce, when using the PHP mail() function

April 11, 2023

When sending email messages using PHP, you must set the envelope sender in order to have bounces handled correctly. In order to set the envelope sender, use the -f sendmail option in the additional_parameters parameter of the mail command. Here is an example:

mail("to@example.com", "subject", "body of message", "From: sender@example.com", "-fsender@example.com");

Without the last parameter, "-fsender@example.com", bounces would come back to a system administrator account, instead of the From address, which is usually not what is intended.