Tags for this FAQ item:
PHP Sendmail

To what extent has this article answered your question?

Be the first to give a rating!

Correct usage of From: headers with mail sent through PHP (sender envelope)

Last updated: 19/01/2016

A well known problem when sending e-mails through webservers is the wrong From: address that by default points to the server's name. This can cause some problems: mails never arrive, replies are sent to a non active or not actively checked mailbox and bounces may arrive at the hosting company or worse disappear in the bitbucket.

In PHP it is relatively easy to fix:


	mail('nobody@yourdomain.com', 'subject', 'message', null, '-f from@yourdomain.com');


The last parameter ' -f ' allows you to specify the From: address for the sendmail function.