Platform
Learn
Developer docs User guide Quickstart Blog
Company
Services About Contact Links Get started

Email templates

Updated

Raytha sends nine system emails: account creation, password changes and resets, password recovery and the one-time login code. Each one is an email template you can edit in the admin. This page lists what sends each email and which variables each can use. It also shows how email Liquid differs from the Liquid in page templates.

The templates

Open Email templates in the admin. Each template has a developer name, a Subject and a Message body. The editor lists the variables available to the template you are editing.

Developer nameSent whenExtra Target members
raytha_email_admin_welcomeAn administrator account is created and the creator chose to send the email.NewPassword, LoginWithEmailAndPasswordIsEnabled, IsNewlyCreatedUser
raytha_email_admin_passwordchangedSomeone changes their own password through the change-password flow. Public users go through the same flow, so they receive this email too.none
raytha_email_admin_passwordresetAn administrator resets another administrator's password.NewPassword
raytha_email_user_welcomeA public user account is created and the email is requested.NewPassword, LoginWithEmailAndPasswordIsEnabled
raytha_email_user_passwordchangedNever. No event uses it, so editing it has no effect.none
raytha_email_user_passwordresetAn administrator resets a public user's password.NewPassword
raytha_email_login_beginforgotpasswordSomeone asks to recover a password.ForgotPasswordCompleteUrl
raytha_email_login_completedforgotpasswordThe recovery is finished.none
raytha_email_login_beginloginwithmagiclinkSomeone asks to sign in with a one-time code.Code, MagicLinkExpiresInSeconds

You cannot add templates, and you cannot delete or rename these. A template that is edited keeps a list of revisions you can revert to.

What an email template can use

An email renders with two variables, CurrentOrganization and Target. There is no CurrentUser, PathBase, QueryParams or ContentType.

CurrentOrganization

The same object as in page templates: OrganizationName, WebsiteUrl, TimeZone, DateFormat, SmtpDefaultFromAddress, SmtpDefaultFromName, HomePageId, EmailAndPasswordIsEnabledForAdmin, EmailAndPasswordIsEnabledForUsers and AuthenticationSchemes.

Target

Every email carries these members. Not every event fills in all of them.

MemberMeaning
IdThe user's id.
FirstName, LastName, FullNameThe name on the account. FullName is the two with a space.
EmailAddressThe recipient.
AuthenticationSchemeDeveloper name of the sign-in method the account uses.
SsoIdThe single sign-on id. Set only by admin_passwordchanged, admin_passwordreset, user_passwordreset and the three login emails.
IsAdminTrue for an administrator. Set only by the three login emails. It is false in all the others.
LoginUrlThe sign-in page for the account's kind. Set in the two welcome emails, admin_passwordchanged, admin_passwordreset, user_passwordreset and login_completedforgotpassword. Empty in the other three.
CustomAttributesListed in the editor but never filled in. Do not use it.

The members in the last column of the table above are added to that email only.

Differences from page templates

  • Subject and Message body are rendered separately, each against the same variables. The Subject is Liquid too: the default is [{{ CurrentOrganization.OrganizationName }}] Password recovery.
  • Output is not escaped. A name containing < is written as it is. Pipe names through escape.
  • The functions and filters from Functions and filters are defined, but there is no request, so there is little reason to use them in an email.
  • The mail is sent as HTML.

Edit one

  1. Open Email templates and choose the template.
  2. Change the Subject and the Message body. Use the variables from the table above.
  3. Save. The next email that event sends uses the new text.
<p>Hi {{ Target.FirstName | default: "there" | escape }},</p>

<p>Someone asked to reset the password for your account at
  <a href="{{ CurrentOrganization.WebsiteUrl }}">{{ CurrentOrganization.OrganizationName | escape }}</a>.</p>

<p><a href="{{ Target.ForgotPasswordCompleteUrl }}">Choose a new password</a></p>

<p>If this was not you, you can ignore this email.</p>

Branch on the account kind in the login emails, which are the ones that set IsAdmin:

{% if Target.IsAdmin %}
  <p>This is an administrator account.</p>
{% endif %}

Sending

Raytha sends mail over SMTP. If no SMTP host is configured, the email is skipped, nothing fails visibly, and a warning is written to the log. Set up the host, the sender name and the sender address first; see Sending emails. The built-in templates do not accept Cc or Bcc, and Raytha refuses to save either on them, for security reasons. The Cc and Bcc boxes in the editor are not used for sending.

Gotchas

  • The welcome and reset emails print Target.NewPassword in plain text, because that is how a user learns an assigned password. Keep it, or replace it with a link to your own password recovery page.
  • raytha_email_user_passwordreset and raytha_email_admin_passwordchanged (which public users also receive) set LoginUrl to the administrator sign-in page, not the public one. Write the public sign-in address into the template instead of using Target.LoginUrl.
  • Target.ForgotPasswordCompleteUrl and Target.Code expire. The default text says the link lasts 15 minutes. If you change the wording, do not promise a different time.
  • An error in an email template is not caught when you save it. The error surfaces when the event runs, for example while an administrator is being created. Check a change by triggering the event, for example by resetting the password of a test account.

Next steps