Documentation menu▾

Emails

Send license keys, team invitations, expiry and trial reminders and payment notices through SMTP or Cloudflare. Customize templates and choose what goes out.

Keygate sends the emails a licensing system needs: login codes, the license key after a purchase, team invitations, reminders before a license or trial runs out and notices about failed payments. All of them go to the customer on your behalf, with your site name on them.

Set up sending

There are two ways to send mail. Both can be set and tested in the dashboard under Settings, Email.

  • SMTP, through any mail service: your own server, Amazon SES, Postmark, Mailgun and so on. You can also set it with the SMTP_* variables in the configuration.
  • Cloudflare Email, which sends over HTTPS. Useful when your host blocks SMTP ports, as many cloud providers do.
.env
SMTP_HOST=smtp.postmarkapp.com
SMTP_PORT=587
SMTP_USERNAME=...
SMTP_PASSWORD=...
SMTP_FROM=Acme Licensing <[email protected]>

Use the Send Test Email button after saving. License keys from Stripe purchases, resent keys and reminder emails go through a queue that retries and survives a restart. Other emails, such as login codes, are retried once and then dropped, so keep the mail server reliable.

Until sending is set up, Keygate still runs. Login codes are written to the server log, and customer emails are not sent.

What Keygate sends

Some emails always go out, because the product does not work without them: login codes, team invitations, the email that delivers a license key, and anything you send by hand, such as resending a key. The rest are automatic and can be turned off:

GroupEmails
RemindersLicense expiring or trial ending soon, subscription renews tomorrow, update period ending soon, Stripe trial ending soon.
License statusLicense expired, trial ended (also when a trial moves to its fallback plan), license suspended, subscription canceled, plan changed.
BillingPayment failed and the reminders that follow, payment recovered, payment needs confirmation.
Usage and accountUsage quota warning, welcome email after the first sign in.

Choosing which emails go out

Under Automated emails in the email settings, each email has its own switch. Turn one off when you would rather send that message yourself, for example from your marketing tool. Several of them also fire a webhook, marked in the list, so your own system can take over the moment you switch the email off.

Each switch covers every case of its email. Trial ended, for example, covers both a trial that expires and a trial that moves to its fallback plan, and the matching webhooks are license.expired and plan.changed with reason trial_ended. See the trial events.

Switching an email off is safe to undo. Reminders that were skipped while it was off are not counted as sent, so the next one that falls due still goes out.

Expiry reminders

Customers whose license or trial is about to run out get a reminder seven, three and one day before the end by default. Change the days under the License expiring or trial ending soon switch: pick a common schedule such as 14, 7 and 1 days, or enter your own, up to five days between 1 and 90.

  • Only one reminder goes out per window, even if a check runs late. A license that first comes within a shorter window gets only that window's reminder.
  • If the license is extended, the schedule starts again from the new date.
  • Subscriptions that renew on their own do not get these. They get a single reminder the day before the card is charged.
  • A trial's reminder says when the trial ends. If the trial plan names a fallback plan, it also names that plan and tells the customer they keep their key on it, instead of saying they will lose access. A trial Stripe bills does not move to a fallback plan, so its reminder never names one.

Trial ended emails

This section covers the email a customer gets when their trial is over. It comes from the Trial Expired template and goes out in both cases:

  • The trial expires. The email asks the customer to subscribe to a paid plan to keep using the product.
  • The trial moves to its plan's fallback plan. The email says which plan the license carries on with, with the same key, and that the plan's limits now apply.

The template tells the two apart with {{.FallbackPlan}}: the fallback plan's name when the trial moved, empty when it expired. A trial that moves does not also get the plan changed email. Both are sent by an hourly check, shortly after the trial's end date.

Team invitation emails

When a license owner invites someone to their team in the customer portal, Keygate emails them an invitation from the Seat Invite template. It names the owner and the product, carries the link to accept, and adds the product's download link if it has one.

  • The link is valid for seven days.
  • Inviting the same person again before they accept sends a new email with a new link, and the old link stops working.
  • The member accepts, signs in to the portal and finds a license key of their own there. That key is not emailed.
  • If every seat is taken when they open the link, they are told no seat is free; the invitation stands and works once the owner frees a seat.
  • A customized template that leaves out {{.InviteURL}} still works: Keygate adds the link at the end of the email.

Invitation emails always go out and have no switch.

Templates

Each of these emails can use your own HTML template, set under Email Templates in the settings. Templates use Go template syntax. Every template can use {{.SiteName}}, your site name, and {{.PortalURL}}, the link to the customer portal, plus the variables of its own email:

TemplateSent whenVariables
License CreatedA license key is delivered: after a purchase or a self sign up, when you issue a license, or when you resend the key.{{.Product}}, {{.Plan}}, {{.LicenseKey}}, {{.DownloadURL}}
License ExpiringAn expiry reminder is due for a license or a trial.{{.Product}}, {{.LicenseKey}}, {{.ExpiresAt}}, {{.DaysLeft}}, {{.IsTrial}}, {{.FallbackPlan}}
Updates EndingThe update period of a perpetual license ends within 14 days, on plans that sell renewals.{{.Product}}, {{.LicenseKey}}, {{.UpdatesUntil}}
License ExpiredA license runs out after its end date and grace days.{{.Product}}
Trial ExpiredA trial expires or moves to its fallback plan.{{.Product}}, {{.FallbackPlan}}
License SuspendedAn admin suspends a license.{{.Product}}, {{.Reason}}
Quota WarningUsage crosses a quota's warning level.{{.Product}}, {{.Feature}}, {{.Used}}, {{.Limit}}, {{.Pct}}
Seat InviteA license owner invites someone to their team.{{.Product}}, {{.Inviter}}, {{.InviteURL}}, {{.DownloadURL}}
Payment FailedThe first reminder after a subscription payment fails.{{.Product}}

What the variables hold:

VariableContains
{{.Product}}Product name.
{{.Plan}}Plan name.
{{.LicenseKey}}The license key.
{{.ExpiresAt}}End date of the license or trial.
{{.DaysLeft}}Days until the license or trial ends.
{{.IsTrial}}True when the reminder is about a trial.
{{.FallbackPlan}}The plan a trial moves to when it ends. Empty when the trial simply expires, and for anything that is not a trial.
{{.UpdatesUntil}}End date of the update period.
{{.Reason}}The reason for a suspension. Suspending from the dashboard gives none, so it is empty.
{{.Feature}}The feature whose quota is filling up.
{{.Used}}, {{.Limit}}, {{.Pct}}Usage so far, the quota, and the share used in percent.
{{.Inviter}}The email of the license owner who sent the invitation.
{{.InviteURL}}The link to accept the invitation.
{{.DownloadURL}}The product's download link, if it has one.
{{.SiteName}}Your site name.
{{.PortalURL}}Link to the customer portal.
License Created
<p>Thanks for buying {{.Product}}.</p>
<p>Your {{.Plan}} license key is <strong>{{.LicenseKey}}</strong>.</p>
{{if .DownloadURL}}<p><a href="{{.DownloadURL}}">Download {{.Product}}</a></p>{{end}}
<p>Manage your license at <a href="{{.PortalURL}}">{{.SiteName}}</a>.</p>

Naming the fallback plan in your templates

If you customized the Trial Expired or License Expiring template before trial fallback plans existed, it does not know about them, and a customer who moves to the free plan would read that their trial is over with no word about what happens next. Add {{.FallbackPlan}}. The template list shows a note on a customized copy of either template that does not use it.

Trial Expired
<p>Your {{.Product}} trial has ended.</p>
{{if .FallbackPlan}}
<p>Your license carries on with the {{.FallbackPlan}} plan, with the same key.</p>
{{else}}
<p>Subscribe to a paid plan to keep using {{.Product}}.</p>
{{end}}
<p><a href="{{.PortalURL}}">Open your account</a></p>

Preview and checks

  • Preview shows a template filled with sample data. In the sample, {{.FallbackPlan}} is empty, as for most trials, so the preview shows the trial expiring.
  • The preview follows plain variables and simple {{if .Field}} conditions. A template that uses more, such as not, or or else if, is shown approximately, and the preview says so. The email as sent may then look different.
  • Keygate renders a template with sample data when you save it, so a syntax error or a misspelled variable is refused right away instead of reaching a customer. If a saved template still fails when an email is sent, Keygate falls back to the built in template and the email goes out anyway.
  • Reset to Default replaces your HTML with the built in template. Copy it out first if you might need it again.

Frequently asked questions

How do I tell trial customers which plan they move to when the trial ends?

The built in Trial Expired and License Expiring templates already do it when the trial plan names a fallback plan. If you customized either template, add {{.FallbackPlan}}, for example {{if .FallbackPlan}}You now use the {{.FallbackPlan}} plan.{{end}}. It holds the fallback plan's name and is empty when the trial simply expires.

Can I turn off team invitation emails?

No. The invitation carries the only link a new member can join with, so it always goes out, like login codes and the email that delivers a license key. You can change its wording with the Seat Invite template.

Last updated October 26, 2026