Emails
Send license keys, expiry reminders and payment notices through SMTP or Cloudflare. Customize templates and choose which emails go out.
Keygate sends the emails a licensing system needs: login codes, the license key after a purchase, reminders before a license 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.
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:
| Group | Emails |
|---|---|
| Reminders | License or trial expiring soon, subscription renews tomorrow, update period ending soon, Stripe trial ending soon. |
| License status | License expired, trial ended, license suspended, subscription canceled, plan changed. |
| Billing | Payment failed and the reminders that follow, payment recovered, payment needs confirmation. |
| Usage and account | Usage 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.
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 or trial expiring 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.
- 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.
Templates
Each email can use your own HTML template, set under Email Templates in the settings. Templates use Go template syntax; these variables are available, depending on the email:
| Variable | Contains |
|---|---|
{{.Product}} | Product name. |
{{.Plan}} | Plan name. |
{{.LicenseKey}} | The license key. |
{{.ExpiresAt}} | End date of the license. |
{{.DaysLeft}} | Days until the license ends, in expiry reminders. |
{{.IsTrial}} | True when the reminder is about a trial. |
{{.DownloadURL}} | The product's download link, if it has one. |
{{.SiteName}} | Your site name. |
{{.PortalURL}} | Link to the customer portal. |
<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>Keygate renders a template with sample data when you save it, so a typo or a misspelled variable is caught 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.
Last updated October 4, 2026