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

What is a DMARC DNS record?

When it comes to sending e-mail, you are often faced with three types of DNS records when setting up domain...

Read more

What is an SPF record?

If you want to prevent your sent mails from ending up in spam or junk folders at the recipient's end...

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