Add style to email with subject "Two-factor authentication disabled"

Problem description

Here are some emails that GitLab sends that currently look totally unstyled:

Screenshot_2023-07-05_at_9.13.58_PM

Source code for email above: https://gitlab.com/gitlab-org/gitlab/-/blob/a679324a3a668b1548f0b5394e0c2874f6c8cf9f/app/mailers/emails/profile.rb#L73-84

Screenshot_2023-07-05_at_9.11.00_PM

Source code for email above: https://gitlab.com/gitlab-org/gitlab/-/blob/a679324a3a668b1548f0b5394e0c2874f6c8cf9f/app/mailers/emails/profile.rb#L160-168

It would be great if all of our notification emails had some styles so they look more official.

Like this email:

Screenshot_2023-07-05_at_9.11.33_PM

Which is added as part of this MR: !124577 (merged)

There is an issue requesting that styles be added to all emails: Improve default email template styling (#215652)

But what if we start with the 2 in the screenshots above? Can we make those look nice?

Implementation guide

For emails without a layout:

  •     def access_token_about_to_expire_email(user, token_names)
          return unless user
    
          @user = user
          @token_names = token_names
          @target_url = profile_personal_access_tokens_url
          @days_to_expire = PersonalAccessToken::DAYS_TO_EXPIRE
    
          Gitlab::I18n.with_locale(@user.preferred_language) do
            mail_with_locale(to: @user.notification_email_or_default, subject: subject(_("Your personal access tokens will expire in %{days_to_expire} days or less") % { days_to_expire: @days_to_expire }))
          end
        end
  •     def disabled_two_factor_email(user)
          return unless user
    
          @user = user
    
          Gitlab::I18n.with_locale(@user.preferred_language) do
            mail_with_locale(to: @user.notification_email_or_default, subject: subject(_("Two-factor authentication disabled")))
          end
        end
  • Instead of mail_with_localeuse the email_with_layout method.

Edited by Jessie Young