Email Templates

Overview

FusionAuth will use email templates to send a Forgot Password request, and other built in workflows. You may also create your own email templates and send them to Users via the Send Email API.

Allowed Content

There are no FusionAuth enforced limits on the content of HTML or text email templates. You can store whatever HTML or text you’d like.

The only validation performed ensures that non-null strings are provided for each template.

The maximum length of an email template is 65,535 bytes due to the database column used.

Managing Templates

FusionAuth ships with several templates to support Forgot Password, Setup Password, Verify Email and other workflows. You will want to modify these templates prior to using them in production.

Apart from modifying them to be more cosmetically pleasing or to match your brand, you will need to ensure the URL used in the template is correct. You will need to ensure the URL is publicly accessible.

The email templates ship with a base URL of http://localhost:9011 for links, such as the verify email or change password link. While this works for local development, for production, make sure to update all base URLs to a public URL, such as https://auth.example.com.

One option is to store a base URL value on the tenant.data object. For example, set tenant.data.baseEmailURL to https://auth.example.com, and then access it from each email template. Setting the tenant.data.baseEmailURL field can be done using the API or the client libraries.

There is currently no support for changing the base URL in all templates in an instance, though there is an open feature request.

When you first log into FusionAuth and navigate to Customizations -> Email Templates you will see the following templates.

Stock Email Templates

For example, below is the email body of the Email Verification template as it is shipped with FusionAuth.

Stock Verify Email Template

At a minimum, you will need to update this URL to a publicly accessible URL that can reach FusionAuth.

If you will be handling Email Verification yourself, you will need to update this URL to be that of your own. You will notice the one replacement variable in this template named ${verificationId}. See the Replacement Variables section below for additional detail, but these variables will be replaced when the template is rendered.

Base Information

Id

The unique Id of the email template. The template Id may not be changed and will be used to interact with the template when using the Email APIs.

Namerequired

The name of the template. This value is for display purposes only and can be changed at any time.

Default Subjectrequired

The default subject of the email. The default value will be used unless a localized version is found to be a better match based upon the User’s preferred locales.

This field supports replacement variables.

From Email

The from email address used to send this template. As of version 1.16.0, this field is optional.

Default from Name

The default from name of the email. The default value will be used unless a localized version is found to be a better match based upon the User’s preferred locales.

This field supports replacement variables.

Localization

The email template body (both HTML and text values), subject, and from name fields can be localized.

You can associate these values with a locale. If a user has a preferred language, the localized template will be used when this email is sent.

A localized email template for the French locale.