Email Templates
STING-CE uses custom-branded email templates for all authentication flows. These templates are styled to match the STING platform design with a modern dark theme and glass-morphism effects.
Overview
Ory Kratos sends emails for:
- Login codes - Passwordless authentication
- Registration - Account verification codes
- Verification - Email address confirmation
- Recovery - Password reset links
All templates are located in:
STING/kratos/courier-templates/
Template Files
| Flow | Body Template | Subject Template |
|---|---|---|
| Login Code | login_code.body.gotmpl | login_code.subject.gotmpl |
| Registration | registration_code.body.gotmpl | registration_code.subject.gotmpl |
| Verification | verification.valid.email.body.gotmpl | verification.valid.email.subject.gotmpl |
| Recovery | recovery.valid.email.body.gotmpl | recovery.valid.email.subject.gotmpl |
Additional Templates
| File | Purpose |
|---|---|
*.body.plaintext.gotmpl | Plain text fallback for HTML emails |
*.body.sms.gotmpl | SMS message templates |
*.invalid.*.gotmpl | Error case templates |
Configuration
Enabling Custom Templates
Templates are enabled via two configurations:
1. Docker Compose Volume Mount (docker-compose.yml):
kratos:
volumes:
- ${INSTALL_DIR}/kratos/courier-templates:/etc/config/kratos/courier-templates:ro
2. Kratos Configuration (kratos.yml):
courier:
smtp:
from_address: noreply@your-domain.com
from_name: STING Platform
template_override_path: /etc/config/kratos/courier-templates/
SMTP Configuration
Email sending is configured in env/kratos.env:
# SMTP Server
COURIER_SMTP_CONNECTION_URI=smtp://mailpit:1025/?skip_ssl_verify=true
# For production (example with SendGrid):
# COURIER_SMTP_CONNECTION_URI=smtps://apikey:YOUR_KEY@smtp.sendgrid.net:465
Template Syntax
Templates use Go’s text/template syntax with Kratos-specific variables.
Available Variables
| Variable | Description |
|---|---|
{{ .To }} | Recipient email address |
{{ .RecoveryURL }} | Password recovery link |
{{ .VerificationURL }} | Email verification link |
{{ .RecoveryCode }} | 6-digit recovery code |
{{ .VerificationCode }} | 6-digit verification code |
{{ .LoginCode }} | 6-digit login code |
{{ .RegistrationCode }} | 6-digit registration code |
{{ .Identity }} | Full identity object |
{{ .Identity.traits.name }} | User’s name from traits |
Example: Login Code Template
<!DOCTYPE html>
<html lang="en">
<head>
<title>🐝 STING Platform - Your Access Code</title>
</head>
<body>
<div class="glass-card">
<h1>Your Login Code</h1>
<div class="code-display">
{{ .LoginCode }}
</div>
<p>This code expires in 15 minutes.</p>
</div>
</body>
</html>
Example: Subject Template
Your STING Login Code: {{ .LoginCode }}
Design Guidelines
STING email templates follow these design principles:
Color Palette
| Element | Color |
|---|---|
| Background | #0f172a (slate-900) |
| Card background | rgba(51, 65, 85, 0.8) |
| Primary text | #f1f5f9 (slate-100) |
| Accent (amber) | #f59e0b |
| Code background | #1e293b |
Typography
- Font: Inter, system fonts fallback
- Headings: Bold, larger size
- Body: Regular, 1.6 line-height
Components
- Glass cards: Backdrop blur with subtle border
- Code display: Monospace, large, amber accent
- Buttons: Amber gradient with hover effects
Testing Emails
Development Mode
In development, emails are captured by Mailpit:
Start with dev profile:
docker compose --profile dev up -dAccess Mailpit UI:
http://localhost:8025All outgoing emails appear in Mailpit for inspection.
Testing Templates
To test a specific template:
- Trigger the flow (login, registration, etc.)
- Check Mailpit for the email
- Verify styling renders correctly
- Check plain text fallback
Customization
Changing Branding
To customize for your organization:
Logo: Replace the SVG in templates or add an
<img>tag:<img src="https://your-domain.com/logo.png" alt="Logo" />Colors: Update the CSS variables in the
<style>blockText: Modify copy in the HTML body
Footer: Update company info and links
Adding New Templates
Create files following naming convention:
your_flow.body.gotmpl your_flow.subject.gotmplReference in
kratos.ymlif neededRestart Kratos:
docker compose restart kratos
Troubleshooting
Emails Not Using Custom Templates
Symptoms: Emails appear as plain text without styling
Causes & Fixes:
Volume not mounted:
# Check if templates are visible in container docker exec sting-ce-kratos ls /etc/config/kratos/courier-templates/Missing template_override_path: Add to
kratos.yml:courier: template_override_path: /etc/config/kratos/courier-templates/Container needs restart:
docker compose restart kratos
Emails Not Sending
Check SMTP configuration:
docker exec sting-ce-kratos env | grep SMTPCheck Kratos logs:
docker logs sting-ce-kratos --tail 50 | grep -i mailVerify Mailpit is running (dev mode):
docker ps | grep mailpit
Template Syntax Errors
If emails fail to render:
- Check Kratos logs for template errors
- Validate Go template syntax
- Ensure all variables are spelled correctly
- Test with minimal template first
Best Practices
- Always provide plaintext fallback - Some email clients block HTML
- Test across email clients - Gmail, Outlook, Apple Mail render differently
- Keep templates simple - Complex CSS may not render
- Use inline styles - External CSS often stripped
- Version control templates - Track changes in git
- Document customizations - Note what you changed and why