Migrating HTML Email Templates to FusionAuth: Best Practices and Considerations
-
Our existing system uses only HTML email templates for password resets, and we are migrating these templates to FusionAuth. We have a few questions:
- What happens if we provide empty strings for the text version of the email templates during migration?
- How does FusionAuth determine whether to send a text or HTML email to a user?
- Is there a way to force FusionAuth to always send HTML emails, as that has been our company's standard practice?
-
- Providing Empty Strings for Text Templates:
While it is technically possible to provide empty strings for the text version of the templates, this is not recommended. FusionAuth sends both the text and HTML versions of the email, with each MIME encoded. The email client decides which version to render. If a user’s email client renders the text version, the email will appear blank if the text template is empty.
Recommendation:
Create a simple text version of the email by stripping out the HTML formatting (e.g., removing <p></p>, <a></a>, etc.). You can refer to FusionAuth's default email templates for examples of how to format text-only emails. - Criteria for Sending Text vs. HTML Emails:
The choice of rendering text or HTML emails is determined by the recipient's email client. Most modern email clients prioritize HTML, but some may fall back to text if they do not support HTML or if the user has configured their preferences for plain text emails. - Forcing HTML Emails:
FusionAuth does not provide a way to force emails to always render in HTML, as the decision ultimately lies with the recipient’s email client. However, providing well-constructed HTML templates ensures that most users will receive the intended design, as HTML rendering is the default behavior for the majority of email clients.
By creating both text and HTML versions of your templates, you ensure compatibility with all email clients while maintaining your preferred HTML formatting for most users.
- Providing Empty Strings for Text Templates:
-