Fixing the WordPress Email Return-Path Header

WordPress LogoEmails sent by WordPress can often end up in the spam folder because of a sub-optimal Return-Path email header. What does that mean and how do you fix it?

The best way to illustrate this problem is with an example. Say you installed WordPress on a server with a Fully Qualified Domain Name (FQDN) of However, the domain name of your WordPress site is In the WordPress admin area under Settings > General you’ve set as your site’s outgoing email address. The only problem is that the mail server software (MTA), such as Sendmail or Postfix, is adding a return-path header to your WordPress emails that looks something like the following:

Return-Path: <>

This does not match the from address of and that is why some spam filters would flag this email as junk mail. So ideally you want the return-path header to match the from header in emails sent by WordPress.

Fixing The Return-Path Header

WordPress has its own function for sending emails called wp_mail which you can find in wp-includes/pluggable.php. To set the correct return-path header you have to plug into the action “phpmailer_init” that is executed just before an email is sent out:

Plugin Name: Email Return Path Fix
Author: Abdussamad Abdurrazzaq
class email_return_path {
  	function __construct() {
		add_action( 'phpmailer_init', array( $this, 'fix' ) );    
	function fix( $phpmailer ) {
	  	$phpmailer->Sender = $phpmailer->From;
new email_return_path();

The above plugin sets the return-path header to equal the from header.

If you are using sendmail on your server you have to take an additional step and add the web server username (usually apache) to your /etc/mail/trusted-users file and restart sendmail. If you don’t do this sendmail will add an X-Authentication-Warning header which is likely to cause your email to end up in the spam folder. You don’t have to take this step if you are using Postfix.

Kudos to Stefano Lissa on the WP forums for writing about this.

36 thoughts on “Fixing the WordPress Email Return-Path Header

    • There can be many reasons for this. Some things you can try are setting an SPF record in your DNS settings for your domain name and implementing DKIM. It would probably be easier to just use a specialist SMTP service like mailgun, mandrill, amazon SES etc. These days it is very hard for a new IP address to build up a good reputation and get accepted as legitimate by the major free email providers. That is why these transactional email providers have made space for themselves.

  1. Can’t install & getting this error message :
    The package could not be installed. PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature

    • Ok, I got it : I was trying to upload, but a simple dir copy did it.
      I’ll now try to reproduce these emails before rejoice too quickly… šŸ˜‰

  2. Thank you for this. I was trying to override the Return-Path header through the wp_mail request without success. Your code fixed the issue for me.


  3. Hi,

    I just installed your plugin, but still got the same problem, the return path is the bouce+… thing that keep email rejected

    Thank you

    • Then you should talk to your hosting provider about this because they are likely changing it at the server level.

  4. Thank you very much for sharing the plugin, with its use I finished a problem that took little more than a week


  5. Really This is great works for me! I have tried many way to solve spam issues but I couldn’t then I got that plugin and its solve my issue. Thank you very much for this nice plugin.

  6. Thank you for this plugin. It is working fine for my booking plugin and contactforms, however with woocommerce it still gets marked as spam.. Any solutions?

  7. Hello

    i have error massage: PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature

    What the problem?

    • if you using the plugin installation option in WP admin then your supposed to upload the zip file as is. alternatively you can unzip the file and upload the folder to wp-content/plugins/.

  8. This still works with the latest WordPress release and Woocommerce confirmation emails! Thanks a lot! I can’t believe this isn’t already part of the standard WordPress releases. What’s the point of confirmation emails/emails in general if they never make it to your users/customers?

  9. Quite honestly… It strikes me as absolutely appalling that this fix is still required in 2017. Five years after this article was written. This should have been incorporated to wordpress a long time ago.

    But yes it still works and for that we all thank you!!

  10. neighborhood people. BabyCenter just isn’t responsible for the precision invosalomon mening
    Salomon Speedcross 3 CS

  11. Determine what jewellery you are going to produce. The first task is usually to decide the jewellery you want to make. Jewelry could be something, including anklets to sophisticated necklaces with significant and also elaborately created pendants and also organizations. The type of jewellery that you just help make determine the difficulty in the process. For instance, producing Japoneses handmade jewelry will still only require a bead arranged, some twine, plus a filling device. On the other hand, you may need a supply of sisalomon mener along with other precious metals if you wish to produce metal jewellery yourself. The sources, moment, and also capability determine the types of jewellery as well as the types of jewellery that should help make.
    salomon ski 2015

  12. You can prefer to buy the inexpensive option. Surgical metal is made up of regarding 8% for you to 12% impeccable. However the impeccable is actually sure securely inside interiors in the metal therefore the impeccable written content won’t communicate with your skin. Using this simple fact cheap it can be less than most gold and sisalomon mener jewelry help make surgical metal a great alternative to anyone who encounters impeccable level of responsiveness.
    orange under armour shoes

  13. Last but not least, produce a schedule that will enable one to fit into creating jewelry with your alternative activities. If you’re producing diamond jewelry as a part period business, many of the crucial. Once you’ve all of these at heart, altering your home straight into diamond jewelry course is achievable.
    curry clutchfit

  14. Obtain directly from factory stores. Makers and companies market goods in discount prices should you buy it on the webpage exactly where it’s produced because there is simply no transport expense included with the product in comparison with its price any time shipped at their receiving stores.
    converse john varvatos

  15. Receiving a artist purse is probably a part of each ladies desire. Occasionally it isn’t in which low-cost, so you would need to wait for sale to call your own artist purse. Be it a drinking straw purse, fashion purse, or even an coordinator purse that will work as cases of your very own goods, there’s a designer shoes for you.
    under armour factory house

Leave a Reply

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