Email

Which emails the starter sends, how to set them up in Loops, the variables each template receives, and what happens when email isn't configured.

Updated · 3 min read

The starter sends its transactional email through Loops, using templates you publish there. Email is optional: without the Loops settings the app runs, but those emails aren't sent and the sign-in page leaves out emailed links. Recipients are never added to a marketing audience.

The emails

EmailWhen it goesTemplate variable
Password resetA user asks at /forgot-passwordLOOPS_RESET_PASSWORD_TEMPLATE_ID
Email verificationSign-up, a resend from the account page, or an email changeLOOPS_VERIFY_EMAIL_TEMPLATE_ID
Sign-in linkA user chooses "Email me a link instead"LOOPS_MAGIC_LINK_TEMPLATE_ID (optional; unset, emailed links are off)
Organisation invitationAn owner or admin invites someoneLOOPS_INVITATION_TEMPLATE_ID
Affiliate noticesApplication decided, commission earned, payout recorded, new application for adminsLOOPS_AFFILIATE_TEMPLATE_ID (optional)
Subscription confirmationSomeone signs up to your list (double opt-in)LOOPS_CONFIRM_SUBSCRIPTION_TEMPLATE_ID
Download linkSomeone requests a gated downloadLOOPS_DOWNLOAD_TEMPLATE_ID
Enquiry noticeSomeone sends the contact formLOOPS_ENQUIRY_TEMPLATE_ID

Every email also needs LOOPS_API_KEY. All of these are server variables. An empty value counts as unset.

Set up Loops

  1. In Loops, verify your sending domain. The sender name and address are set on each Loops template; the code has none.
  2. Publish a transactional template for each email you want, using the variables in the next section.
  3. Set LOOPS_API_KEY and the template ids on the server: in apps/server/.env locally, or on server in Railway.
  4. Restart or redeploy the server.

Start with the three account emails (reset, verification, invitation). Until they're set, people can't reset a password, and invitations need their link shared by hand.

Template variables

Each email sends these data variables to its template:

VariableSent withValue
urlEvery emailThe action link: reset, verify, sign in, accept, confirm or download
nameEvery emailThe recipient's name; for invitations, the inviter's name; empty for a sign-in link to a new address
organizationNameInvitationsThe organisation's name
subject, bodyAffiliate notices, enquiriesThe notice's subject and text
unsubscribeUrlSubscription confirmation, download linkThe one-click unsubscribe page
titleDownload linkThe download's title
replyToEnquiriesThe visitor's address

The sign-in link template needs url for its button and may greet with name. Tell the reader the link works once and expires in 5 minutes.

When email isn't configured

  • At start-up the server logs a warning naming the missing settings for the reset, verification and invitation emails.
  • A request that needs a missing email gets "Email delivery is not configured. Contact your administrator."
  • If Loops refuses or can't be reached, the user sees "Email delivery failed. Please try again later." Loops' own response is never shown.
  • Sign-up never fails because of email. A failed verification email is logged and the account is still created.
  • Invitations are created without email; owners and admins copy the link from the organisation page.
  • Affiliate notices are logged in development and skipped elsewhere.

Account emails are not printed to the console. To test reset and verification locally, configure Loops with test templates. Audience emails are the exception: in development, one whose template isn't set is logged with its link, so you can try signups and downloads without Loops. Admin → Audience warns while any of the three audience templates is missing.

Audience sync

Transactional email never enrols anyone in marketing. To copy confirmed subscribers into your Loops audience, set LOOPS_AUDIENCE_SYNC=true. Confirming adds the contact as subscribed, unsubscribing marks them unsubscribed, and deleting a subscriber in Admin → Audience removes them from Loops. A failed sync is logged and never undoes the change. See Analytics and the audience.

Using another provider

All email goes through one sender function on the server. To switch provider, replace that function's body and keep its errors, so nothing that calls it changes. Then replace the LOOPS_* variables with your provider's. Email is only ever sent from the server, which is the only place that holds the API key.

Something unclear or missing? Ask us and we'll answer, then fix the page.