I'm using the Post SMTP Plugin, but I manually send email via the wp_mail() function. The gmail client shows the correct From:, but when I switch to outlook or another email client, shows the different Sender: (the one that has been set up in the Post SMTP From: setting)

I have tried these filters, but only the wp_mail_from_name works:

add_filter( 'wp_mail_from', create_function('', 'return sanitize_email("test@abv.bg"); ') );
add_filter( 'wp_mail_from_name', create_function('', 'return "Test Testov"; ') );

How can I force-change that sender?

EDIT: Paul G., in Gmail I see this: from: Correct Name <c.name@mydomain.com>

and in another email client this:

From: Correct Name

Sender: default@mydomain.com <---- This is wrong.

有帮助吗?

解决方案

First Disable PostSMTP plugin and delete if not used anymore it should cleanup.
Then in functions.php add the following lines

// Function to change email address
function sender_email( $original_email_address ) {
    return 'tim.smith@example.com';
}
 
// Function to change sender name
function sender_name( $original_email_from ) {
    return 'Tim Smith';
}
 
// Hooking up our functions to WordPress filters 
add_filter( 'wp_mail_from', 'sender_email' );
add_filter( 'wp_mail_from_name', 'sender_name' );

Taken from : WPBeginner

其他提示

Switched the Mailer Type from PostSMTP to PHPMailer and it fixed the issue.

许可以下: CC-BY-SA归因
scroll top