mails being rejected at aol or yahoo or gmail?

If you send mails using a webform using the php mail() function and your mails are being rejected by the destination servers here’s a small trick to fix the issue.

Usually this arises when your envelop does not carry a valid identifiable from header. So instead of using something like:

mail($to, $subject, $message, $headers);
Where you are not explicitly setting the sender address try something like this:
mail($to, $subject, $message, $headers,"-femail@domain");

This would set the correct from address in your mail envelop. Usually the address is picked up from php.ini on the server and if not mentioned it is set to the webuser@hostname

It’s a good practise to set the fifth field on your mail() function as it prevents confusion at the recipient end.

Leave a Reply

Your email address will not be published. Required fields are marked *