I have a WordPress site where i have Issue with the email, that user receives after creating an account.
Email that a user receives, looks like this:
There is no formatting, no paragraph or no line breaks etc in the email. I have tried fixing this by adding filter for wp_new_user_notification_email but it did not worked: I have tried fixing it by using following:
add_filter('wp_new_user_notification_email', 'tpkcs_welcome_email', 10, 3);
function tpkcs_welcome_email($wp_new_user_notification_email, $user, $blogname)
{
$wp_new_user_notification_email['headers'] = 'Content-Type: text/html; charset=UTF-8';
return $wp_new_user_notification_email;
}
I have also tried this:
// Add content Type to emial template
function kcss_set_content_type(){
return "text/html";
}
add_filter( 'wp_mail_content_type','kcss_set_content_type' );
But none of the filters/actions worked either.
I have a WordPress site where i have Issue with the email, that user receives after creating an account.
Email that a user receives, looks like this: https://tinyurl.com/y45bgy5z
There is no formatting, no paragraph or no line breaks etc in the email. I have tried fixing this by adding filter for wp_new_user_notification_email but it did not worked: I have tried fixing it by using following:
add_filter('wp_new_user_notification_email', 'tpkcs_welcome_email', 10, 3);
function tpkcs_welcome_email($wp_new_user_notification_email, $user, $blogname)
{
$wp_new_user_notification_email['headers'] = 'Content-Type: text/html; charset=UTF-8';
return $wp_new_user_notification_email;
}
I have also tried this:
// Add content Type to emial template
function kcss_set_content_type(){
return "text/html";
}
add_filter( 'wp_mail_content_type','kcss_set_content_type' );
But none of the filters/actions worked either.
Share Improve this question edited Sep 23, 2021 at 6:42 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Sep 23, 2021 at 6:26 Sajid ManzoorSajid Manzoor 1031 silver badge7 bronze badges 2- Does it look like this in all email clients? WordPress emails are plain text by default and this looks like the email client just isn't displaying it correctly, which is not a WordPress issue. – Jacob Peattie Commented Sep 23, 2021 at 8:15
- Yes, this is diplayed like this in all email clients. i know be default, wordpress sends plain text email. But i want it to be formatted with like breaks so it can be readable easily – Sajid Manzoor Commented Sep 23, 2021 at 14:43
1 Answer
Reset to default 0I had the same issue.
I finally succeed to display the message with proper line breaks by surrounding the body of the message $wp_new_user_notification_email['message']
,in your case, with html tags (html, head, body) and filtering it with nl2br
.
Hope it will help.