Making sure receives PHP Mail() emails

During the recent development of I had found my current setup of Postfix which is used by PHP Mail() was not sending email correctly to Microsoft email services such as

Emails were being sent by my web server but never received by or placed in the Junk folder, even though emails were received fine by Gmail with the same server settings.

I found some help on various websites regarding this issue which I have now implemented on my server, I have posted the configuration below which I now working for me.

These steps below have been tested on a Digital Ocean VPS running ZPanel 10.1.0.

1. The first step is to check your domain and/or IP address is not listed on a spam block list. Use to check for blocked domains and IP addresses. If the domain and/or IP address is listed on a spam block list, then it should be removed.

2. Add a Windows Sender ID SPF record to your domain’s DNS settings. This helps Microsoft services to understand your domain and/or web server IP address is not used for sending spam emails. This can be setup at this web address: [Link no longer available: 23/07/2016].

3. Always make sure there is a valid ‘From:<[email protected]>’ address in the headers of your PHP Mail() code. It must be a full email address and not just a domain, an example of the correct script setup is below:
4. Then edit your ‘’ Postfix file, usually stored in ‘/etc/postfix/’ on your web server. Starting on line 23, your network settings must be the same as below. Replace ‘’ with your domain name.


Tom Byford
  • April 27th, 2014

Thanks for posting this, it’s really helped me when setting up my new web server.


Brad Stone
  • July 10th, 2014

Hi, When setting up the server, will the above code work on a Windows 2008 server? or is this just for Linux. Any help would be great, thanks. Although I guess it will work on both because this is PHP code? Thanks

  • July 27th, 2014

Hi Brad, the code should work on any server which uses the PHP mail function.

Post a Comment