<@U04UQ68083H> I am trying to update the email tem...
# ory-copilot
h
@chilly-king-10285 I am trying to update the email templates locally, but the HTML is not being rendered. However, the subject is. How to fix?
b
A message from kapa.ai
If your custom email template's subject is being rendered but the HTML body is not, there are a few common issues to check: 1. Both HTML and Plaintext Are Mandatory For each email template, you must provide both an
html
and a
plaintext
version. If either is missing or misconfigured, the system may fall back to the default template or not render the HTML at all. Make sure your configuration includes both fields under the
body
key:
Copy code
yaml    courier:      templates:        verification:          valid:            email:              body:                html: base64://<ENCODED_HTML_TEMPLATE>                plaintext: base64://<ENCODED_PLAINTEXT_TEMPLATE>              subject: base64://<ENCODED_SUBJECT>
The
html
field must contain your HTML template, and the
plaintext
field must contain the plain text version. Both must be present and properly encoded in base64, prefixed with
base64://
if you are using Ory Network or the base64 method in self-hosted setups. If you are self-hosting, you can also use
file://
or
http://
URIs for templates, but both
html
and
plaintext
are still required [Mandatory template formats](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#mandatory-template-formats) [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates). 2. Correct Template Path and Configuration In self-hosted Ory Kratos, ensure your templates are located at the expected paths and referenced correctly in your configuration. For example: -
<kratos-root>/<template-root>/verification/valid/email.body.gotmpl
-
<kratos-root>/<template-root>/verification/valid/email.body.plaintext.gotmpl
If the system can't find or use your custom templates, it will fall back to the built-in ones 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). 3. Base64 Encoding If you are using base64 encoding, ensure your HTML template is correctly encoded and prefixed with
base64://
. You can encode your template using:
Copy code
echo "Your custom template" | base64
Then, add it to your config as shown above [Using custom message templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#using-custom-message-templates). 4. Template Syntax Make sure your HTML template is valid and does not contain syntax errors. Ory uses Go's
html/template
engine for HTML templates, so invalid syntax can cause rendering issues [Creating templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#creating-templates). 5. Fallback Behavior If the HTML template is missing or invalid, Ory may fall back to the plaintext version or the default template. Double-check logs for any errors related to template rendering. Summary: - Ensure both
html
and
plaintext
templates are present and correctly configured. - Use the correct encoding and file paths. - Check for syntax errors in your HTML template. - Review logs for any template-related errors. If you follow these steps and the issue persists, please provide your configuration and template file paths for further troubleshooting.