Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29762

WordPress notifications not received in G-mail with altered header information

$
0
0

I have customized the default welcome e-mail send out by WordPress when you add a user, but when I change the default "From" information it no longer gets delivered to @gmail.com e-mailaddresses. I have tried it with multiple accounts, but always the same results. I haven't had any problems with @hotmail.com or any custom domain e-mailaddresses.

Below is the function I used to alter the default e-mail:

// Change the default welcome e-mail
add_filter( 'wp_new_user_notification_email', 'welcome__email', 10, 3 );

function welcome__email( $wp_new_user_notification_email, $user, $blogname ) {

     $wp_new_user_notification_email['subject'] = sprintf(__( 'Company Name | Complete registration' ), $blogname, $user->user_login );

     // Set password link
     $key = get_password_reset_key( $user );

     // Build the email
     $message = sprintf(__('Welcome!')) . "\r\n\r\n";
     $message .= 'By clicking the link below you can activate your account:' . "\r\n";
     $message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . "\r\n\r\n";
     $message .= "After setting a password you can login." . "\r\n";

     $wp_new_user_notification_email['message'] = $message;

     // Change header information
     $wp_new_user_notification_email['headers'] = 'From: Company Name <noreply@example.com>'; 

     return $wp_new_user_notification_email;

}

If I comment out the last part about the 'headers' the e-mail with link to set a password does get delivered to @gmail.com e-mailaddresses, but ofcourse the default name and e-mailaddress are show then.

I can't see what I am missing out here to make sure the e-mails get delivered to @gmail.com addresses, so I'm hoping anybody here is able to help me in the right direction.

PS: I do not have any SMPT plug-in set-up.


Viewing all articles
Browse latest Browse all 29762

Trending Articles