How to send custom HTML email for reset password?

I know there will be a hook for that (retrieve_password_notification_email)

But how to use it?

Requesting for an example


1 Answer 1


It was achieved using two hooks.

  1. retrieve_password_notification_email
  2. retrieve_password_message
function ashad_retrieve_password_notification_email($defaults) {
    $defaults['headers'] = array('Content-Type: text/html; charset=UTF-8');
    return $defaults;
add_filter('retrieve_password_notification_email', 'ashad_retrieve_password_notification_email', 10, 3);

function ashad_reset_password_message($message, $key, $user_login, $user_data )    {
    $user_fullname = $user_data->user_firstname . ' ' . $user_data->user_last_name;
    $blog_name = get_bloginfo('name');
    $reset_url = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login');
    include(get_stylesheet_directory() .  '/templates/mail/password-change.php');
    $message = ob_get_clean();
    return $message;
add_filter("retrieve_password_message", "ashad_reset_password_message", 99, 4);

retrieve_password_notification_email hook is used to set the header of the email as HTML and the retrieve_password_message hook is used to set the message from the password-change.php template file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.