plain-lunch-50969
08/05/2025, 4:36 PMbrief-egg-61061
08/05/2025, 4:36 PMbrief-egg-61061
08/05/2025, 4:36 PMplain-lunch-50969
08/05/2025, 4:37 PMplain-lunch-50969
08/05/2025, 4:37 PMbrief-egg-61061
08/05/2025, 4:37 PMbrief-egg-61061
08/05/2025, 4:37 PMyaml courier: template_override_path: /conf/courier-template templates: verification: valid: email: body: html: <https://some-remote-resource/gotmpl> plaintext: <base64://SGV5IHlvdSBkZWNvZGVkIG1lIDop> subject: <file://some-file/subject.gotmpl>
Both the html
and plaintext
fields are mandatory when defining the body
key. If the system can't use the custom templates, it will fall back to the built-in templates or to the template_override_path
if specified [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates). Summary: - In self-hosted Ory Kratos, you can load email templates via https://, file://, or base64://. - Base64 encoding is not required unless you prefer it or are using Ory Network (Cloud).plain-lunch-50969
08/05/2025, 4:38 PMbrief-egg-61061
08/05/2025, 4:38 PMbrief-egg-61061
08/05/2025, 4:39 PMhtml
and plaintext
fields are set under the body
key. - If you use a remote URL (https://), make sure the URL is accessible from your Kratos instance and returns the expected template content. - The template_override_path
should point to the correct directory if you are using local files. The expected structure is: - <kratos-root>/<template-root>/recovery/valid
- <kratos-root>/<template-root>/verification/valid
- etc. - If the system can't use the custom templates, it will fall back to built-in templates or the template_override_path
if specified [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates). 2. File Permissions and Accessibility - If using file-based templates, ensure the Kratos process has read permissions for the template files. 3. Template Format - Both html
and plaintext
versions are mandatory. If either is missing or invalid, the template may be ignored [Mandatory template formats](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#mandatory-template-formats). 4. Restart Kratos - After changing templates or configuration, restart your Kratos instance to ensure changes are loaded. 5. Logs and Error Messages - Check Kratos logs for any errors or warnings related to template loading or email delivery. Errors here can indicate missing files, permission issues, or template parsing problems. 6. Testing Template Override - Try using a simple template to rule out syntax errors. For example, set the plaintext template to a simple string and see if it appears in the email. 7. Multiple Instances - If running multiple Kratos or courier instances, ensure all have access to the templates [Mail courier in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-selfhosted). If after these steps your template is still not used, double-check the config structure and paths, and consult the logs for specific error messages. If you need more detailed troubleshooting, please provide relevant log output or error messages. If you want to view outgoing messages and their status, you can also check the Email Delivery page in the Ory Console if you are using Ory Network, but for self-hosted, rely on your local logs [Use a custom server to send Ory Identity messages to users](https://www.ory.sh/docs/kratos/emails-sms/sending-emails-smtp#troubleshooting).plain-lunch-50969
08/05/2025, 5:23 PMbrief-egg-61061
08/05/2025, 5:23 PMbrief-egg-61061
08/05/2025, 5:23 PMcourier.templates.verification_code.valid.email.body
section in your configuration file. You can provide the template using a file://
, http(s)://
, or base64://
URI. Both html
and plaintext
fields are required. Here’s an example configuration: yaml courier: templates: verification_code: valid: email: body: html: file:///path/to/your/verification_code_valid_email.body.gotmpl plaintext: file:///path/to/your/verification_code_valid_email.body.plaintext.gotmpl
Or, if you want to use an HTTPS URL for the HTML template: yaml courier: templates: verification_code: valid: email: body: html: <https://your-domain.com/templates/verification_code_valid_email.body.gotmpl> plaintext: file:///path/to/your/verification_code_valid_email.body.plaintext.gotmpl
Make sure both files exist and are accessible by the Kratos process. If the templates are not found or not valid, Kratos will fall back to the built-in templates or the template_override_path
if specified [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates). Note: - The verification_code.valid
template is used when the verification method is set to "code" [Available variables](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#available-variables). - Both html
and plaintext
versions are mandatory [Mandatory template formats](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#mandatory-template-formats). If you use a template_override_path
, the expected directory structure is: <template-root>/verification_code/valid/email.body.gotmpl <template-root>/verification_code/valid/email.body.plaintext.gotmpl
This allows Kratos to locate your custom templates automatically [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates).plain-lunch-50969
08/05/2025, 5:42 PMcourier:
templates:
verification_code:
valid:
email:
body:
html: file:///etc/kratos/templates/verification.valid.email.body.html.gotmpl
plaintext: file:///etc/kratos/templates/verification.valid.email.body.plaintext.gotmpl
subject: file:///etc/kratos/templates/verification.valid.email.subject.gotmpl
brief-egg-61061
08/05/2025, 5:42 PMbrief-egg-61061
08/05/2025, 5:43 PMverification_code: valid: email: body: html: file:///etc/kratos/templates/verification.valid.email.body.html.gotmpl plaintext: file:///etc/kratos/templates/verification.valid.email.body.plaintext.gotmpl subject: file:///etc/kratos/templates/verification.valid.email.subject.gotmpl
According to the documentation, the expected directory structure for self-hosted Kratos is: <template-root>/verification_code/valid/email.body.gotmpl <template-root>/verification_code/valid/email.body.plaintext.gotmpl <template-root>/verification_code/valid/email.subject.gotmpl
Your file names use verification.valid.email.body.html.gotmpl
instead of the expected verification_code/valid/email.body.gotmpl
. This mismatch may cause Kratos to not find your templates [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates). 2. Template Type The config section you are using is for the verification_code
flow, not verification
. Make sure your flow is actually using verification by code, not by link, as the template keys differ [Email templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates). 3. File Accessibility You mentioned the files are readable in both pods, which is good. Double-check that the file contents are valid Go templates and that both html
and plaintext
are present and non-empty [Mandatory template formats](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#mandatory-template-formats). 4. Logs Check the logs of both the Kratos and kratos-courier pods for any errors or warnings related to template loading or parsing. Kratos will fall back to built-in templates if it cannot load or parse your custom templates [Mail courier in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-selfhosted). 5. Restart Pods After making changes to templates or configuration, ensure you restart both the Kratos and kratos-courier pods so they reload the templates. Summary of debugging steps: - Rename your template files and directory structure to match the expected pattern: /etc/kratos/templates/verification_code/valid/email.body.gotmpl
/etc/kratos/templates/verification_code/valid/email.body.plaintext.gotmpl
/etc/kratos/templates/verification_code/valid/email.subject.gotmpl
- Update your config to point to these files or use the template_override_path
to set the root directory. - Check logs for errors. - Restart your pods after changes. If you follow these steps and still encounter issues, please provide any relevant log output for further assistance.plain-lunch-50969
08/05/2025, 5:45 PMbrief-egg-61061
08/05/2025, 5:45 PMbrief-egg-61061
08/05/2025, 5:45 PMfile://
URI does allow you to specify an absolute path to any file on the filesystem, and you are not required to use the default directory structure or file names. The documentation states: > In self-hosted Ory Kratos instances, you can add custom templates from http://
, file://
, and base64://
URIs. The plaintext
and html
fields are mandatory when defining the body
key. All other keys are optional. If the system can't use the custom templates, it falls back to the built-in templates or to the template_override_path
(if specified) [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates). This means you can place your template files anywhere on the filesystem and use any file name, as long as your configuration points to the correct path using the file://
URI. The default directory structure is only required if you use the template_override_path
mechanism, not when specifying explicit file://
URIs in your config. If your templates are not being used, the issue is likely not with the file location or name (when using file://
), but could be related to file permissions, template validity, or another configuration issue.plain-lunch-50969
08/05/2025, 5:46 PMbrief-egg-61061
08/05/2025, 5:46 PMbrief-egg-61061
08/05/2025, 5:46 PMplain-lunch-50969
08/05/2025, 7:51 PMbrief-egg-61061
08/05/2025, 7:51 PMbrief-egg-61061
08/05/2025, 7:51 PMtext/template
and html/template
engines. For HTML templates (email.body.gotmpl
), you should use HTML tags like <br>
or <p>
to create new lines or paragraphs, as plain newlines in the template file will not be rendered as line breaks in the resulting email. For plaintext templates (email.body.plaintext.gotmpl
), newlines in the template file should be preserved in the sent email, as long as the receiving email client displays them as such [Mandatory template formats](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#mandatory-template-formats). Example for HTML template: html Hello {{ .Identity.traits.firstName }},<br> Please use the following code:<br> {{ .VerificationCode }}
Example for plaintext template: Hello {{ .Identity.traits.firstName }}, Please use the following code: {{ .VerificationCode }}
If you are seeing all text in one line, ensure you are editing the correct template type (HTML vs. plaintext) and using the appropriate formatting for that type. If you are using an HTML template, plain newlines will not create line breaks in the rendered email; you must use <br>
or similar HTML tags [Mandatory template formats](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#mandatory-template-formats).plain-lunch-50969
08/05/2025, 7:52 PMbrief-egg-61061
08/05/2025, 7:52 PMbrief-egg-61061
08/05/2025, 7:52 PMhtml
and plaintext
versions of an email template when sending messages. The html
version is used to provide rich formatting and features (like clickable links), while the plaintext
version is used as a fallback for email clients that do not support HTML or when HTML is blocked. The documentation specifies: > Each template must have two versions: html
and plaintext
. > - html
version uses the HTML syntax to achieve the desired look and functionality (such as clickable buttons) of the email message. > - plaintext
version can't contain any HTML. Must contain only plain text content and any necessary gotmpl
logic. This version is used as a fallback when the html
version cannot be delivered, for example when the user's mail server blocks HTML in all incoming messages. > > [Mandatory template formats](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#mandatory-template-formats) So, the courier sends both versions in the email, and the recipient's email client decides which one to display. If the client supports HTML, it will show the HTML version; otherwise, it will show the plaintext version.