<@U04UQ68083H> i have a template in self hosted en...
# ory-copilot
a
@chilly-king-10285 i have a template in self hosted environment:
<!DOCTYPE html>
<html lang=“en”> <head> <meta charset=“UTF-8"> <meta name=“viewport” content=“width=device-width, initial-scale=1.0"> <title>Verify Your Account</title> <style> body { font-family: -apple-system, BlinkMacSystemFont, ‘Segoe UI’, Roboto, ‘Helvetica Neue’, Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0; background-color: #F8F9FA; } .container { max-width: 600px; margin: 0 auto; background-color: #FFFFFF; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); overflow: hidden; } .header { background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%); color: white; padding: 30px 20px; text-align: center; } .header h1 { margin: 0; font-size: 24px; font-weight: 600; } .content { padding: 40px 30px; } .verification-code { background-color: #F8F9FA; border: 2px solid #E9ECEF; border-radius: 6px; padding: 20px; text-align: center; margin: 30px 0; font-family: ‘Courier New’, monospace; font-size: 24px; font-weight: bold; color: #495057; letter-spacing: 2px; } .button { display: inline-block; background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%); color: white; text-decoration: none; padding: 15px 30px; border-radius: 6px; font-weight: 600; margin: 20px 0; text-align: center; transition: transform 0.2s ease; } .button:hover { transform: translateY(-1px); } .footer { background-color: #F8F9FA; padding: 20px 30px; text-align: center; color: #6C757D; font-size: 14px; } .security-note { background-color: #FFF3CD; border: 1px solid #FFEAA7; border-radius: 4px; padding: 15px; margin: 20px 0; color: #856404; } .divider { border-top: 1px solid #E9ECEF; margin: 30px 0; } </style> </head> <body> <div class=“container”> <div class=“header”> <h1>🔐 Verify Your Account</h1> </div> <div class=“content”> <p>Hello!</p> <p>Thank you for signing up! To complete your account verification, please use one of the methods below:</p> <div class=“verification-code”> {{ .VerificationCode }} </div> <p><strong>Option 1:</strong> Enter the verification code above in your application.</p> <div style=“text-align: center;“> <a href=“{{ .VerificationURL }}” class=“button”> 🔗 Verify Account Now </a> </div> <p><strong>Option 2:</strong> Click the button above to verify your account automatically.</p> <div class=“security-note”> <strong>🔒 Security Note:</strong> This verification link will expire in 10 minutes for your security. If you didn’t request this verification, please ignore this email. </div> <div class=“divider”></div> <p style=“font-size: 14px; color: #6C757D;“> If you’re having trouble with the button above, copy and paste this link into your browser:<br> <a href=“{{ .VerificationURL }}” style=“color: #667EEA; word-break: break-all;“>{{ .VerificationURL }}</a> </p> </div> <div class=“footer”> <p>This email was sent to verify your account. If you didn’t create an account, you can safely ignore this email.</p> <p>&copy; {{ now.Format “2006" }} Your Company Name. All rights reserved.</p> </div> </div> </body> </html>
c
A message from kapa.ai
Your HTML template is suitable for use as a custom verification email in a self-hosted Ory Kratos environment, but there are a few important requirements and steps you must follow to ensure it works correctly: ### 1. Template Variables Your template uses the correct variables for verification emails: -
{{ .VerificationCode }}
-
{{ .VerificationURL }}
These are supported for the
verification_code.valid
template (for code-based verification) and the
verification.valid
template (for link-based verification). You can also use variables like
{{ .To }}
,
{{ .Identity }}
, and
{{ .ExpiresInMinutes }}
if needed, as described in the documentation [Available variables](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#available-variables). ### 2. Template Format Ory Kratos requires both an HTML and a plaintext version for each template. The HTML version can be your provided template. The plaintext version should be a simple text-only version with the same information, without any HTML tags [Mandatory template formats](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#mandatory-template-formats). ### 3. File Placement and Configuration For self-hosted Ory Kratos, you can provide templates via
file://
,
http://
, or
base64://
URIs. You must specify both
html
and
plaintext
fields in your configuration. For example:
Copy code
yaml courier:   templates:     verification:       valid:         email:           body:             html: file:///path/to/your/verification_valid_email.body.gotmpl             plaintext: file:///path/to/your/verification_valid_email.body.plaintext.gotmpl
Alternatively, you can use
base64://
or
http://
as needed. If you want to use a template override directory, set `template_override_path`:
Copy code
yaml courier:   template_override_path: /conf/courier-template
Ory Kratos expects templates at these paths (relative to the override path): -
verification/valid/email.body.gotmpl
-
verification/valid/email.body.plaintext.gotmpl
- (and similar for
invalid
) See [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates). ### 4. Template Syntax Ory Kratos uses Go templates (
gotmpl
). Your template should use standard Go template syntax. For example, for the copyright:
Copy code
html &copy; {{ now.Format "2006" }} Your Company Name. All rights reserved.
This is correct Go template syntax. ### 5. Example Directory Structure If using
template_override_path: /conf/courier-template
, your files should be:
Copy code
/conf/courier-template/verification/valid/email.body.gotmpl /conf/courier-template/verification/valid/email.body.plaintext.gotmpl
### 6. Reloading After updating templates or configuration, restart your Kratos instance to apply changes. --- Summary: Your template is compatible, but ensure you provide both HTML and plaintext versions, use the correct Go template syntax, and configure the paths as required by Ory Kratos. For more details, see the official documentation on [self-hosted email templates](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates) and [custom email templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#mandatory-template-formats).
a
@chilly-king-10285 this template is locally in : ory/kratos/config/templates/verification/valid/email.body.html.gotmpl as well as ory/kratos/templates/verification/valid/email.body.html.gotmpl to check if one works but both do not work. kratos: kratos: depends_on: - kratos-migrate image: oryd/kratos:v1.1.0-distroless ports: - ‘4433:4433’ # public - ‘4434:4434’ # admin restart: unless-stopped environment: - DSN=postgres://kratos:root@host.docker.internal:5432/kratos?sslmode=disable - LOG_LEVEL=trace volumes: - ./kratos/config/:/etc/config/kratos - ./kratos/templates/:/conf/courier-templates command: serve -c /etc/config/kratos/kratos.yml --dev --watch-courier networks: - intranet courier: template_override_path: /conf/courier-templates smtp: connection_uri: smtps://test:test@mailslurper:1025/?skip_ssl_verify=true
c
A message from kapa.ai
Based on your configuration and the official Ory documentation, here are the key points to check for your self-hosted Kratos email template setup: ### 1. Template Path and Naming - The
template_override_path
is set to
/conf/courier-templates
. - Kratos expects templates at paths like:
Copy code
<template_override_path>/verification/valid/email.body.gotmpl
Note: The file must be named
email.body.gotmpl
(not
email.body.html.gotmpl
). The
.gotmpl
extension is required, and the system distinguishes between
gotmpl
(for HTML) and
plaintext.gotmpl
(for plain text) [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates). ### 2. File Placement Given your Docker volume mapping:
Copy code
yaml - ./kratos/templates/:/conf/courier-templates
Your local directory structure should be:
Copy code
./kratos/templates/verification/valid/email.body.gotmpl ./kratos/templates/verification/valid/email.body.plaintext.gotmpl
Do not use
.html.gotmpl
as the extension; use
.gotmpl
for HTML and
.plaintext.gotmpl
for plain text. ### 3. Configuration Example Your
kratos.yml
should include:
Copy code
yaml courier:   template_override_path: /conf/courier-templates   smtp:     connection_uri: <smtps://test:test@mailslurper:1025/?skip_ssl_verify=true>
### 4. Restart Required After making changes to templates or configuration, you must restart the Kratos container for changes to take effect [Mail courier in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-selfhosted). ### 5. Troubleshooting - Log Level: You have
LOG_LEVEL=trace
, which is good for debugging. Check the logs for any template loading errors. - Fallback: If the template is not found or is misnamed, Kratos will fall back to the built-in template or the default path. --- Summary of likely issue: Your template file should be named
email.body.gotmpl
(not
email.body.html.gotmpl
) and placed at
/conf/courier-templates/verification/valid/email.body.gotmpl
inside the container. The same applies for the plaintext version as
email.body.plaintext.gotmpl
. Double-check the file names and paths according to the documentation [Email templates in self-hosted Ory Kratos](https://www.ory.sh/docs/kratos/self-hosted/mail-courier-templates). If you follow this structure and restart Kratos, your custom template should be picked up. If it still does not work, review the logs for specific errors about template loading.