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

Category: Email

PHP Sendmail

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:

<?php

 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.


Related articles

Apache - Install SSL Certificate

This article assumes you've received your certificate from the Certificate Authority, and that you wish to install it on your...

Read more

How can I move (transfer) a .com, .net or .org domain name?

If you would like to move (transfer) a domain name (typically com, .net or .org) from your current registrar to...

Read more

How can I publish my website via FTP?

If you use shared web hosting at Kinamo, either Linux hosting or Windows hosting, you can use an FTP program...

Read more

Need extra help?

Were not all your questions answered?
Don't worry, we will be happy to help you via a support request!

Kinamo

Select your language