Last updated on 06 Sept 2023, 13:16:48.
Category:
All about web hosting
| Webhosting settings
Apache CentOS Debian PHP Sendmail SMTP Wordpress
The problem with mails sent through Wordpress - whether it is by using Contact Form 7 plugin or others - is the way the wp-mail function (which most of these plugins use) sends e-mail.
Wordpress uses the PHP mail function. Sending mail with the PHP mail function is no problem of course, but often the return-path header of the message isincorrect. This makes messages end oup in spam and junk folders or worse, they never arrive. All very exciting, but how can you fix it?
The return-path can be set up at server level, through the php.ini file or with an additional parameter setting the From: header which is passed to the PHP mail function.
The best way to explain this, is with an example: the mail is sent from Wordpress on domain name www.mywordpressblog.be, but the site itself runs on a cluster of webservers, so for the server, the sender is not www.mywordpressblog.be but one of the web nodes, for example. web-php55-l01.hosting.kinamo.be.
Through the Wordpress settings you have set up the sender with your e-mail address (webmaster@mywordpressblog.be) but this is not enough: for the mail server (MTA), for example postfix, the return-path header is added if not available, so this becomes:
Return-Path: <apache@web-php55-l01.hosting.kinamo.be>
This is not correct, since it does not match your @mywordpressblog.be address.
<?php /* 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(); ?>
Have fun!
Were not all your questions answered?
Don't worry, we will be happy to help you via a support request!