PhoenixKit.Email.CoreTemplates (phoenix_kit v2.55.1)

Copy Markdown View Source

The emails core itself sends, as PhoenixKit.Email.Catalog entries.

Each email's default copy is a named function here, not a closure at the send site, because two callers need the same copy: the send (PhoenixKit.Users.Auth.UserNotifier, PhoenixKit.Mailer.send_magic_link_email/2) and the admin preview. One function means the preview can never show copy the send no longer uses.

Every *_defaults/0 is a zero-arity function so PhoenixKit.Email.Content can evaluate it inside the recipient's locale — see "Why the default is a function" there.

The defaults are Markdown (PhoenixKit.Email.Markdown): the main action is a button — a paragraph that is exactly one [label]({{url}}) link — with the address written out under it for a reader whose client does not show the button, and the plain-text body is derived from the same Markdown. A host that overrides text.txt alone still gets its own words in both bodies (see "Which part makes which body" in PhoenixKit.Email.Content).

notification is the exception: its body is the notification's own text, already rendered in the reader's language, so its default is a plain text part with nothing to translate.

Summary

Functions

The catalog entries for core's emails, in the order the admin lists them.

The {{failed_attempts}} paragraph of the new login alert for count failures in the last 24 hours: empty (not "0") when there were none, else a sentence carrying its own trailing blank line, so the paragraph collapses cleanly instead of leaving a gap.

Default copy of the failed sign-in alert (failed_login_alert).

The {{location}} line of the new login alert: the geolocated place, marked approximate, or "Unknown".

Default copy of the magic link sign-in email (magic_link).

Default copy of the magic link registration email (magic_link_registration).

Default copy of the new login alert (new_login_alert).

Default of the notification email (notification): the subject is the notification's title (or the start of its text), the body its text and link. Nothing to translate — both arrive rendered in the reader's language.

Default copy of the organization invitation (organization_invitation).

Default copy of the account confirmation email (register).

Default copy of the password reset email (reset_password).

Default copy of the email change confirmation (update_email).

Default copy of the welcome email (welcome), sent once an address is confirmed.

The variables of the welcome email for email: the address, and the site name and address the layout's footer shows ({{site_name}}, {{site_url}}), so the button leads where the footer does.

Functions

entries()

@spec entries() :: [PhoenixKit.Email.Catalog.entry()]

The catalog entries for core's emails, in the order the admin lists them.

Labels and descriptions are evaluated on the call, so call this in the locale they should read in. Defaults and sample variables are closures, evaluated later by the preview in the locale being previewed.

failed_attempts_note(count)

@spec failed_attempts_note(non_neg_integer()) :: String.t()

The {{failed_attempts}} paragraph of the new login alert for count failures in the last 24 hours: empty (not "0") when there were none, else a sentence carrying its own trailing blank line, so the paragraph collapses cleanly instead of leaving a gap.

failed_login_alert_defaults()

@spec failed_login_alert_defaults() :: PhoenixKit.Templates.defaults()

Default copy of the failed sign-in alert (failed_login_alert).

location_line(location)

@spec location_line(term()) :: String.t()

The {{location}} line of the new login alert: the geolocated place, marked approximate, or "Unknown".

IP geolocation is city-accurate at best and routinely a hundred kilometres out. Saying so is the difference between a reader dismissing a genuine alert because the city looks wrong and a reader checking the device.

new_login_alert_defaults()

@spec new_login_alert_defaults() :: PhoenixKit.Templates.defaults()

Default copy of the new login alert (new_login_alert).

notification_defaults()

@spec notification_defaults() :: PhoenixKit.Templates.defaults()

Default of the notification email (notification): the subject is the notification's title (or the start of its text), the body its text and link. Nothing to translate — both arrive rendered in the reader's language.

organization_invitation_defaults()

@spec organization_invitation_defaults() :: PhoenixKit.Templates.defaults()

Default copy of the organization invitation (organization_invitation).

register_defaults()

@spec register_defaults() :: PhoenixKit.Templates.defaults()

Default copy of the account confirmation email (register).

reset_password_defaults()

@spec reset_password_defaults() :: PhoenixKit.Templates.defaults()

Default copy of the password reset email (reset_password).

update_email_defaults()

@spec update_email_defaults() :: PhoenixKit.Templates.defaults()

Default copy of the email change confirmation (update_email).

welcome_defaults()

@spec welcome_defaults() :: PhoenixKit.Templates.defaults()

Default copy of the welcome email (welcome), sent once an address is confirmed.

welcome_variables(email)

@spec welcome_variables(String.t()) :: %{required(String.t()) => String.t()}

The variables of the welcome email for email: the address, and the site name and address the layout's footer shows ({{site_name}}, {{site_url}}), so the button leads where the footer does.