HTML code not working for Password Reset email

Created on 6 December 2024, 4 months ago

I have enabled these settings:

Default Message Format...
Default Content Type: HTML
Always use the default content type: checked
Text format: Plain text (this is the only given option)

Generate alternative plain text version (recommended).: checked

Character Set: UTF-8

I then added some basic HTML to my password reset message at /admin/config/people/accounts.

When I submit a password reset, the HTML code appears as plain text. How can I make it so that the HTML code is used to format the email message accordingly?

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States hockey2112

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @hockey2112
  • πŸ‡¦πŸ‡ΊAustralia thomwilhelm Sydney

    Same issue here, did you find a solution? In gmail it comes through as:

    <p>You may now log in by clicking this link or copying and pasting it into
    your browser:</p>

    etc etc.

  • πŸ‡ΊπŸ‡ΈUnited States hockey2112

    No, I ended up removing the html.

  • Status changed to Closed: works as designed about 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States zengenuity

    It's not safe to allow emails to be sent from your site with HTML that may have been entered by untrusted users. For password reset emails, it would probably be fine, but we can't generalize that to everything, such as Webform emails where users can enter anything.

    If you want to change the content type of emails for password resets, you can do it in a custom module with a simple hook:

    <?php
    /**
     * Implements hook_mail_alter().
     */
    function YOUR_MODULE_NAME_mail_alter(&$message) {
      if ($message['module'] === 'user' && $message['key'] === 'password_reset') {
        $message['params']['content_type'] = 'text/html';
        $message['params']['text_format'] = 'restricted_html';
      }
    }
    ?>

    If you add something like that to your site, you can then include HTML markup in the template.

    Alternatively, you can use the Easy Email module β†’ , and override the password reset with an HTML template. That's what we're doing with Drupal CMS. The easiest way to apply this to your site is with the Express Mail recipe β†’ .

  • I was using Easy email and its not working

Production build 0.71.5 2024