I want to send custom email using function.php file..I have added filter to support HTML in email content as mentioned below.
function set_content_type() {
return "text/html";
}
add_filter('wp_mail_content_type', 'set_content_type');
It works fine with my custom email but, Email which are sending by CRED i.e forgot password does not support HTML.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marc,
Thank you for contacting our support forum.
Is the mail that you are trying to send generated from CRED ?
Please let me know.
Thanks,
Shane
Hi Shane,
The filter I have mentioned above is for my custom email which I am sending through function.php it is working fine for my custom email, but not for forgot password Email.
I have created page for forgot password and in that I have put shortcode to display it.
Please have a look at my code for custom email
add_action('edit_user_profile_update', 'send_user_details');
function send_user_details($user_id) {
$all_meta_for_user = get_user_meta($user_id);
if ($all_meta_for_user['wpcf-user-state'][0] == 1 && $_POST['wpcf']['user-state'] == 3) {
$newpwd = random_password();
wp_set_password($newpwd, $user_id);
$userdata = get_userdata($user_id);
$to = $userdata->data->user_email;
$subject = "ICISA - Login Details";
$content = "<p>Hi " . $userdata->data->user_login . "</p>";
$content .= "<p>You are approved by admin.Please login using ".get_page_link(113)."</p>";
$content .= "<p>Email : " . $userdata->data->user_email . "</p>";
$content .= "<p>Password : " . $newpwd . "</p>";
$content .= "<p>Thank You</p>";
wp_mail($to, $subject, $content);
}
}
/**
* set_content_type [set content type text/html for email]
* @param {void} [no input param]
* @return {void} [returns nothing]
*/
function set_content_type($content_type) {
return "text/html";
}
add_filter('wp_mail_content_type', 'set_content_type');
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Marc,
Thanks for the more detailed information, but the forget password i believe is a default wordpress mail.
Could you try this plugin and let me know if it helps.
https://wordpress.org/plugins/custom-forgot-mail/
Thanks,
Shane
Hi Shane,
After doing research I fixed it my self.Instead of custom filter for content I have passed header parameter in wp_mail..Now, It works fine.
Thanks