: How to set the "from" sender in WHM or how to prevent the server from overwriting it? I am using wordpress. Wordpress has its own mail function called wp_mail(), which is very similar to the
I am using wordpress. Wordpress has its own mail function called wp_mail(), which is very similar to the php mail() function.
The wp_mail function allows you to pass headers, such as the "From" field. Several plugins make use of that (for instance gravity forms).
However, when I check the mail logs in WHM I noticed that all "From" fields are either root@mydomain.com or myCpanelAccount@mydomain.com
It looks like the server is either overwriting or ignoring the headers passed by wordpress.
Has anyone experienced similar issues? Are there any settings I can check in WHM to prevent this from happening?
More posts by @Miguel251
1 Comments
Sorted by latest first Latest Oldest Best
This is intended by your hosting company to prevent spam, phishing and fraudulent activities taking place on their servers. They will 'REWRITE' the origin server when you send email that is unauthenticated and cPanel. Generally most hosting companies will operate this way and your not the only one with this problem with PHP mail from header rewrites.
This is due to the fact your not actually sending the email from @example .com but rather your@cpanel-hosting.net, therefore the origin server must be displayed.
The end-user can read the header whom sent it, but the reply-to will be the email you are spoofing. You can fix this issue by using good email-sending practice methods that will improve delivery success rates and will help to prevent your mail from being classified as spam.
To solve the issue you must send the emails using your email account, and not spoofing the email using the simple out of the box wp_mail.
This can be done using plugins such as Contact Form 7, but if you prefer a method that doesn't involve installing plugins then you can use a functions.php method.
Something like this in your functions.php:
add_action( 'phpmailer_init', 'wpse8170_phpmailer_init' );
function wpse8170_phpmailer_init( PHPMailer $phpmailer ) {
$phpmailer->Host = 'your.smtp.server.here';
$phpmailer->Port = 25; // could be different
$phpmailer->Username = 'your_username@example.com'; // if required
$phpmailer->Password = 'yourpassword'; // if required
$phpmailer->SMTPAuth = true; // if required
// $phpmailer->SMTPSecure = 'ssl'; // enable if required, 'tls' is another possible value
$phpmailer->IsSMTP();
}
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.