Customizing Keycloak email templates: what it changes and when you need it
Keycloak sends email for several flows: verifying a new account, resetting a password, inviting a user, and notifying users about events such as new sign-ins or updated credentials. Out of the box, these messages carry default wording and the generic Keycloak look. When your organization needs them to match its brand, use its own tone, or explain its own support path, you change them through an email theme, not by forking the Keycloak server. An email theme is a set of files that Keycloak loads in place of the built-in ones. It holds the FreeMarker templates that define each message, the message bundles that supply the translatable text, and the HTML and plain text versions of each template. Keeping these changes in a theme means the server code stays stock, which keeps later upgrades far simpler.
Teams usually need this work in a few recurring situations. Branded verification and password reset emails are the most common, because those messages reach users before they have any reason to trust the sender. Invitation emails matter when administrators onboard staff or customers into a realm and the wording must name the organization and the correct next step. Event notices, such as alerts about new sign-ins, deserve review by your security and legal teams because they describe account activity in your words. Multiple languages add a further layer, since each language needs its own message bundle entries and its own checks. Before you start, decide which messages you will change, who approves the wording, and which sender address and domain your mail system will use. Confirm the current template names and bundle keys against the Keycloak version you run, because they can change between releases.
This page does not cover branding the login pages, the account console or the admin console. Those screens use separate theme types and are handled in their own sections. The work here sits entirely in the email theme, so a change to a login page will not alter any email, and the reverse is also true. Before you plan delivery, check that the Keycloak server can reach your mail relay with the transport security your policy requires. The Keycloak server administration guide describes how realms and themes are configured, and you should confirm the exact steps for your version there.
Which emails Keycloak sends and what a theme can change
Keycloak sends several kinds of email, and each one reaches a different person at a different point in the user lifecycle. Before editing anything, list which messages your users will actually receive, who they go to, and which parts your team wants to control, because each type has its own template and its own variables.
Email verification
Sent to a newly registered or changed address so the user can confirm ownership before sign-in continues. It is usually the first email a user sees from your realm, so sender name, subject and link wording affect trust directly. Confirm the template name and the link variable for your release in the Keycloak server administration guide, and test that the link still works behind your reverse proxy hostname.
Keycloak docsPassword reset
Sent when a user starts a reset from the login page. The team usually wants clearer wording, a link that expires as stated in policy, and a note telling users to report unexpected requests. Because this email carries a credential recovery link, check each change with a test account and confirm the expiry text matches the realm's actual token lifetime.
Invitation and account setup
Sent when an administrator or an onboarding process creates a user who must set a password or complete required actions. The recipient is often a new employee or partner who has never seen your brand, so organization name, support contact and language matter most. Confirm which required actions the invitation triggers in your release, since those steps appear after the link is opened.
Event and notification emails
Sent for account events such as a new sign-in from an unrecognized device, a credential change or a removed authenticator. These messages are often the only alert a user gets about account misuse, so the team should review wording for clarity and make sure the security-relevant details are present. Confirm which events trigger email in your release and whether each one can be enabled per realm.
Custom emails from your own flows
Messages your team adds for its own extensions, such as a step-up notice or a custom required action confirmation. Keycloak does not ship these templates, so your theme must provide the FreeMarker file and your code must send the message through the realm's mail configuration. Document the variables you pass, because a later Keycloak upgrade may change the built-in set but will not update your custom templates.
Sender identity and layout
The sender address, sender display name, HTML layout and plain text version apply to every message the realm sends. Changing these in one place is cheaper than editing each template, but a layout change can break mail clients that strip styles. Ask your mail provider to confirm SPF, DKIM and DMARC alignment for the sender domain, and send test messages to several client types before go-live.
Options for changing Keycloak email content and look
This table compares four ways to change Keycloak email content and appearance, from editing message text to maintaining a custom email theme per realm or client. Read each row against your own upgrade cadence and the number of languages and email types you must support. The main takeaway is that message bundle changes are the cheapest to keep, while template overrides carry the most upgrade and testing exposure.
| Option | Fit | Maintenance effort and upgrade exposure | Testing burden |
|---|---|---|---|
| Message bundle text only | Wording changes to subject lines and body text in one or a few languages | Low effort. Bundle keys can shift between releases, so review changed keys after each upgrade | Low. Send each email type in every language you support |
| Edit the default email theme in place | Quick experiments in a development environment only | High exposure. Edits to the shipped theme are overwritten or conflict on upgrade and are hard to audit | Medium. Every upgrade requires a full re-test of all email types |
| Custom email theme that extends the default | Brand-specific HTML layout, logos and template structure across the organization | Moderate effort. Keep overrides small and confirm which templates the release lets you inherit | Medium to high. Test HTML and text versions in each client and language |
| Per realm or client template overrides | Different senders, branding or wording for tenants, business units or applications | Highest effort. Each override set is a separate maintenance item that must be reviewed on every upgrade | High. Multiply the test matrix by each realm, client and language |
| Template changes that alter links or tokens | Only where a required flow needs a different action link or variable | High exposure. Changes to link handling can break verification or reset flows after an upgrade | High. Test the full verification and password reset paths end to end |
| Confirm inheritance behavior for your release | Required before choosing any option that extends or overrides the default theme | Confirm in the documented theme inheritance behavior for your exact Keycloak version | Plan retesting whenever the release changes how themes are resolved |
How an email theme reaches the user's inbox
The path starts with a user action such as self-registration, a reset request, an invitation or an event that triggers a message. Keycloak selects the email theme for the realm or client, loads the FreeMarker template and the message bundle for the user's locale, and builds both the HTML and text parts. The SMTP settings configured on the realm then hand the message to your relay, which crosses the boundary out of Keycloak's network. Check the locale fallback, the sender configuration and the relay's StartTLS requirement, since those are where delivery most often fails.
Email theme and SMTP settings path from a user action to the recipient's inbox.
Setting up a custom Keycloak email template
This sequence takes a Keycloak realm from the default email pages to a custom email theme that renders correctly in each supported language, sends through StartTLS SMTP, and links back to the public frontend hostname. The output is a tested theme package enabled on the realm, with test messages checked for every email type.
Confirm the Keycloak release and theme inheritance
Confirm the exact Keycloak release running in your environment, then read the server administration guide and upgrading notes for that release to see how the email theme and its base templates are organized. Decide which built-in theme your custom email theme will extend, so that any template you do not override keeps inheriting the upstream version. Record the release and the base theme in your change ticket. Done when you can name the release, the parent theme and the list of templates you plan to override. Confirm the template names against your own release, because they can change between versions.
Create the email theme package and folder structure
Create a theme directory with an email folder that holds the templates and a theme.properties file that declares the parent theme and locale settings. Keep the folder layout the same as the built-in themes so Keycloak finds the files without extra configuration. Place the directory in your source control repository, not on a running server, so that changes are reviewed and reproducible. Packaging for deployment depends on how you run Keycloak, so confirm the approach your deployment uses. Done when the theme builds locally and the folder tree matches the structure the server administration guide describes for your release.
Copy and edit the email templates and message bundles
Copy only the email templates you need to change, such as verification, password reset, invitation and event notifications, from the parent theme into your package. Keep the FreeMarker syntax and variables intact, and edit the HTML and plain text versions together so both carry the same content. Move user-facing strings into message bundle properties files per language rather than hardcoding text in templates. Avoid copying templates you do not change, because each copy is a file you must recheck at every upgrade. Done when a diff against the parent templates shows only the intended edits and every changed string is in a bundle. Confirm the sign-off with your legal or communications owner for any wording change.
Enable the theme for the realm
In the realm settings, select your custom theme for email, leaving login, account and admin themes set as they were so that only the email output changes. Confirm the realm internationalization settings list each locale you have translated, and that a default locale is set. Make the change in a non-production realm first, then repeat it in production through the same configuration process. Done when the realm shows your email theme selected and a test user in each locale receives messages that use your templates rather than the built-in ones.
Configure SMTP with StartTLS
Configure the realm SMTP settings with your mail relay host, port, sender address and authentication, and enable StartTLS. Keycloak 26.8 enforces StartTLS without plaintext fallback, so the server must offer a valid certificate and a relay that supports StartTLS, which your mail team should confirm before testing. Store the SMTP credentials in your secrets mechanism rather than in exported realm files. Done when a test connection from the admin console succeeds and the server logs show an encrypted session with the relay.
Render every email type in every supported locale
Trigger each email type from a test realm, including verification, password reset, invitation and any event notification you have changed, once for each supported locale. Check that subject lines, body text and placeholders render without missing keys, broken FreeMarker output or untranslated fragments, and that the HTML and plain text versions match. Review right-to-left locales separately if your organization serves them. Done when a written checklist shows every email type and locale rendered, with a reviewer sign-off for each.
Confirm links and send test messages
Inspect every link in the rendered messages and confirm that each one resolves to the public frontend hostname, not the internal hostname or the admin console hostname. Check that action tokens and expiry text match your policy and that the sender address is accepted by your mail system. Send test messages to mailboxes on your main mail providers and confirm inbox placement and rendering. Done when every link resolves to the public frontend URL, the mailbox tests pass, and the results are saved with the release record so the same checks can be repeated after upgrades.
Testing email delivery before users see changes
A local or development realm is the fastest place to find template errors. Developers run Keycloak with the email theme mounted, trigger each message type (verification, password reset, invitation and event notifications), and read the output before any mail leaves the network. Use a capture tool such as a local SMTP sink so nothing reaches a real inbox, and keep test realms free of production user data.
- HTML and text rendering: Open each HTML message in a few common mail clients and confirm the text version reads correctly without styles or images.
- Locale selection: Set the user's locale and confirm the right message bundle is used, with a fallback to the realm default when a translation is missing.
- Links and tokens: Check that action links point to the expected frontend host and that the link expiry shown in the message matches the realm setting.
- Sender and headers: Confirm the From address, reply-to and subject line match what your organization has approved.
- Error logs: Watch the Keycloak server log for FreeMarker parse errors or missing template messages, since a broken template may fail silently for the user.
The development team typically signs off here, and the sign-off should cover the templates and bundles only, not deliverability.
Staging should match production as closely as possible, including the SMTP path. Point the staging realm at a sandbox mail relay or a test mailbox service that your organization already uses, so you can check how messages travel through the same kind of infrastructure production will use. This is where delivery problems and header issues appear.
- SMTP StartTLS enforcement: The Keycloak 26.8 upgrade notes enforce StartTLS without plaintext fallback. Confirm early that your sandbox relay supports StartTLS and that its certificate is trusted, or staging email will fail after upgrade.
- Spam scoring: If your mail team has a spam-scoring tool or a relay that reports authentication results, run test messages through it and record SPF, DKIM and DMARC outcomes.
- Sender headers: Check the envelope sender, message ID and any list or automated-message headers against your mail policy.
- Link behavior: Click each link from a real device, including links that open on a different browser or domain, to confirm the flow completes.
- Failure handling: Stop the relay on purpose and confirm the error appears in the server log with enough detail for the operations team.
The platform team and the mail or messaging owner should sign off together, because the results depend on relay settings that neither group controls alone.
Production testing should be small and deliberate. Use dedicated test accounts on controlled mailboxes that belong to the team, and send only the message types that changed. Schedule the test outside peak sign-in periods and keep the rollback theme ready, so a problem can be reversed quickly without changing the realm configuration.
- Scope of messages: Send only the templates that changed, and record which realm, theme version and locale each test used.
- Real delivery path: Confirm messages arrive in the expected folder for each test mailbox, using the production relay and its authentication settings.
- Live links: Follow each link to the production frontend and confirm the token is accepted and expires as documented.
- Monitoring: Watch bounce notices, relay logs and Keycloak errors for the test window, and check the metrics or log pipeline you already run for email failures.
- Change record: Keep the test results with the change ticket so auditors and operators can see what was verified and by whom.
The application or identity owner signs off on user-facing content, and the security or operations lead signs off on the delivery path before the change is released to all users.
Keeping email customizations through Keycloak upgrades
Every customized email template is a maintenance item. When Keycloak changes the variables a template receives, the message keys it reads, or the default templates shipped in a release, your copy of a template keeps its old content and can silently diverge from what the server expects. The risk is not that the upgrade fails outright. A verification or invitation email may render with a missing value, fall back to a default text you no longer intended, or stop sending a link that a new flow requires. Before an upgrade, list every template file and message key you override, and treat that list as the inventory the upgrade has to clear.
Keep the override set small so that the inventory stays short. Copy only the templates whose layout or wording you must change, and rely on the parent theme for everything else. Put wording changes into message bundles where possible instead of editing template markup, because bundle keys are easier to compare across releases. Record each changed template and key, the reason for the change, and the Keycloak version it was last checked against. Store the theme in version control next to the realm configuration so the record and the files move together. Ask your DeployOpen contact or internal platform owner to confirm which keys your theme depends on before you commit to a particular theme structure.
Read the upgrading guide for each target version and check the email-related notes against your inventory before you deploy. Keycloak's backwards compatibility policy for releases says that breaking changes in a minor release are opt-in, which narrows the set of changes you should expect in a minor upgrade, but it does not remove the need to test. Retest every email type your realm sends after each upgrade, including verification, password reset, invitation, required action and event notification emails, in each language you serve, and confirm that links and tokens still resolve. Ask your team to confirm the test matrix and who signs off on it, since a template that passes review in one language can still break in another.
Security risks in customized email templates
Email templates are one of the few places where Keycloak sends content you wrote to people who have not yet signed in. The risks below sit in the template markup, the mail transport, the sender domain and the process that publishes changes, so a control has to be applied at each layer.
Token-bearing links in templates
Verification, password reset and invitation emails carry action links that contain single-use tokens. A template that adds extra links, analytics redirects or copies of the URL into other fields can leak those tokens to third-party services or logs. Check every link in each template against the link Keycloak generates, and confirm that no added element rewrites or duplicates it. Treat any link that reaches an admin console or the Administration REST API as a defect, since those endpoints should sit on a separate hostname from public frontend URLs.
Keycloak production guideUnescaped user-supplied values
Templates can print user attributes such as first name, last name or custom profile fields. If a template renders these values without escaping, a crafted name can inject markup or misleading content into a message that appears to come from your organization. Use FreeMarker's default escaping for HTML templates, review any place where a value is output with raw or unescaped handling, and test with names containing angle brackets and quotation marks before release.
Phishing-like wording
Users learn to trust the look of security mail. A template that asks for passwords, shortens the sender identity, adds urgency or uses a link text that does not match its target makes legitimate messages hard to tell from attacks. Keep action wording factual, name the product and organization clearly, and state that Keycloak will never ask for a password by email. Ask your security team to review wording changes the same way they review sign-in pages.
SMTP credentials and TLS settings
Mail delivery depends on SMTP settings that hold a username and password. Store those credentials in a secret manager or environment variable, not in realm exports or theme files. Require encrypted transport: the 26.8 upgrade notes state that SMTP StartTLS is enforced without plaintext fallback, so confirm your relay accepts StartTLS before upgrading, and do not reintroduce a plaintext option to make a test succeed.
Keycloak upgrading guideSender domain authentication
Messages that claim your domain without SPF, DKIM and DMARC alignment are easy to spoof and often land in spam, which pushes users toward unofficial reset links. Ask the mail team to confirm that the sending address domain publishes SPF and DKIM records for the relay and a DMARC policy, and that the From address in the realm matches that domain. Verify the records after every change to the sending service, since a new relay often needs its own DKIM key.
Access to the theme repository
Email themes are files on the server or in a container image, so anyone who can change them can change what users receive. Keep theme source in version control with protected branches, require review of template diffs, and limit deployment rights to the people who ship server images. Record which build contains which template so that a suspicious message can be traced to a specific change.
Questions buyers ask about Keycloak email template work
What drives the cost of a Keycloak email theme project?
The main driver is how many email types change and how many languages they must cover. Each email type, such as verification, password reset, invitation and event notifications, needs its own FreeMarker template, subject and body copy, and HTML and plain text versions. Cost rises with the number of realms and themes that share or override templates, the amount of design work needed to match brand guidelines, and the number of mail clients the result must render correctly in. Ask any partner to quote each email type, each language and each realm separately, so you can see where the effort sits and which parts recur when copy changes. Because the work is fixed-scope in DeployOpen's engagements, the written scope is what the quote follows from.
How long does a typical Keycloak email template change take?
Duration depends on how much is changing and how much of it is already decided. A copy-only update to one email type that uses the existing theme is usually short, while a new branded set covering several languages takes longer because translations, design approval and testing each add a review step. The main delays are usually waiting for approved wording, confirming which realms and clients use which theme, and getting SMTP access for test sends. No duration figure is supplied for this work, so ask the partner to state the milestones and the client inputs they expect in the written scope before you commit to a date.
What does the client need to provide for email template work?
The work depends on several inputs from your side. You need approved copy for every email type and language, a decision on which realms and clients each theme applies to, and brand assets such as logos and colors. The build also needs an SMTP relay the test environment can reach, with credentials and sending rules agreed in advance. Plan for test accounts in each realm and in each language so every template can be triggered end to end. Confirm these inputs with your security team early, because SMTP access and sending domains often require approval outside the platform team.
Can our own team build and maintain Keycloak email templates alone?
Yes, a team with Keycloak and FreeMarker experience can build email themes in-house, and the Keycloak server administration guide describes how themes are packaged and selected. The practical question is whether the team has the time and skills to test every email type across languages, handle HTML rendering in common mail clients and keep templates aligned with the Keycloak version in use. Many organizations split the work: internal staff own the copy and approvals, while a partner builds and tests the theme. Compare both options against your release calendar and the number of people who can review a change.
How are translations of Keycloak email messages kept current?
Translations live in message bundles, one per language, so each new or changed key in the English bundle must be carried into every other bundle that the realm supports. Keep a single owner for the bundle files, a documented process for sending new strings to translators, and a test step that triggers each email in each locale before release. Missing keys are a common cause of mixed-language emails, so review them every time copy changes. Ask a partner how they track keys across languages and who signs off on translated wording.
What happens to a custom email theme after a Keycloak upgrade?
Keycloak releases come often, with four minor releases a year planned since Keycloak 26.0, so a custom email theme needs a regression check at each upgrade. Templates that depend on internal template variables or message keys can break or render differently after a change, and the upgrade notes for each release list changes that may affect them. Keep overrides small, keep copy in message bundles, and retest every email type in every language after each upgrade. Upgrade cost therefore recurs with each release you adopt, so include it in the ongoing support scope you agree.
Do email delivery settings affect how templates behave in production?
Yes. Keycloak's 26.8 upgrade notes enforce SMTP StartTLS without plaintext fallback, so the relay you test against must support StartTLS with valid certificates, or messages will not send. Sender addresses, reply-to settings and SPF, DKIM and DMARC alignment also affect whether emails reach inboxes, even when the template is correct. Test delivery against the same relay and sending domain that production uses, and confirm the relay setup with your mail team before the first release.
What to confirm in your environment before customizing Keycloak email
Email theme work is only as reliable as the environment that sends it. The six items below cover the Keycloak release, the mail relay, the sending domain, the languages you must support, compliance review and any event-driven emails, so you can confirm each one before a template is written.
Exact release and template set
Confirm the Keycloak version you run and the template files shipped with it. Email templates are FreeMarker files inside the theme, and template names and variables can change between releases. Check the upgrade notes for your target version, then compare your overridden templates against the shipped set so you know which ones need rework before an upgrade. Record the version next to every custom template.
Keycloak upgrading guideStartTLS support on the SMTP relay
Confirm with your mail team that the SMTP relay accepts STARTTLS on the port Keycloak will use. The Keycloak 26.8 upgrade notes enforce StartTLS without plaintext fallback, so a relay that cannot negotiate TLS will stop email delivery after the upgrade. Test the connection with the exact host, port and credentials that Keycloak uses, not a generic mail client.
Keycloak upgrading guideSender domain and DNS authentication
Confirm the sender address domain, its SPF record, DKIM signing and DMARC policy with your DNS and mail administrators. Emails from a domain without these records are more likely to land in spam or be rejected, and this problem looks like a template fault. Ask who owns the DNS zone and how long a change takes to propagate before you schedule a template launch.
Required languages and bundle coverage
List every language your users need for verification, reset and invitation emails, then check which message bundles already exist for each one. Missing keys fall back to another locale or to the key name, which users see as broken text. Confirm who will translate and review each bundle, and who maintains them when the English source text changes.
Compliance review of email content
Confirm whether your legal, privacy or compliance function must approve the wording of security-relevant emails, such as password reset, account change or invitation notices. Some organizations require fixed disclaimers, retention of sent copies, or a named owner for each template. Agree the approval path and the change record before the first edit, because review cycles often set the schedule more than the build does.
Dependence on event listeners
Confirm whether any email you plan to send is triggered by a custom Event Listener SPI provider rather than by Keycloak's built-in flows. Custom event emails depend on that provider's code, its delivery and retries, and its own upgrade path, so a theme change alone will not fix them. Identify the owner of each listener and whether it runs in the same deployment as the theme.
How DeployOpen scopes and delivers Keycloak email template work
DeployOpen plans and builds Keycloak email themes as part of a self-hosted Keycloak deployment inside your own infrastructure. Each engagement starts with a written scope that names the emails to change, the languages to cover and the delivery tests that must pass before go-live.
How we scope
- We list every email type in scope: verification, password reset, invitation and event notifications, each with its template and locale.
- We confirm which realms and clients use the custom email theme and which keep the default look.
- We agree in writing how SMTP delivery will be tested, including the sending account and the mailboxes used for checks.
How we build
- We create the email theme with FreeMarker templates, keeping HTML and plain text versions aligned for each message.
- We move wording into message bundles per language, so text changes do not require editing template logic.
- We limit template overrides to the files that must change, which keeps future Keycloak upgrades cheaper to review and apply.
How we hand over
- We deliver the theme source, packaging steps and a deployment runbook your team can repeat in each environment.
- We document each overridden template, the message keys changed and the reason for each change.
- We provide test evidence from sample sends across clients, languages and mail clients, so your reviewers can confirm results.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- We retest email templates when Keycloak versions change, since upgrade notes can affect SMTP and template behavior.
- We agree on who handles content edits, translations and sender configuration after go-live, and record that split in the scope.

