Email System Guide — Svelte Templates, SMTP, & Notifications in SveltyCMS
Configure SMTP delivery, responsive Svelte email components with Tailwind CSS v4 inlining, Nodemailer transport, and automated system alerts.
On this page
SveltyCMS features a powerful, template-driven email system that leverages Svelte components for rendering and Nodemailer for SMTP delivery. This system is integrated across the CMS, powering authentication emails, system alerts, and user-defined automations.
Core Concepts
1. Svelte-Based Templates
Emails are built using standard Svelte components located in src/components/emails/. This allows for:
- Better-Svelte-Email: Leveraging the
better-svelte-emaillibrary for high-quality, component-based email construction. - Full Tailwind CSS v4 Support: Create stunning, responsive, and flexible layouts using the Tailwind CSS utility-first approach. SveltyCMS automatically inlines these styles during rendering for 99% client compatibility.
- Dynamic Content: Passing props to templates just like any regular Svelte component.
- Type Safety: Defining strict prop interfaces for each template using TypeScript.
2. Automatic Style Inlining
SveltyCMS uses @better-svelte-email/server as its email rendering engine, which processes Tailwind CSS v4 classes at runtime. This means you can use classes like bg-blue-500 or p-4 in your Svelte files, and they will be converted to inline style="background-color: #3b82f6; padding: 1rem;" attributes in the generated email HTML.
3. Zero-Configuration Preview (Dev Mode)
When running in development mode or when SMTP is not configured, SveltyCMS skips actual SMTP delivery. The rendered email HTML is logged to the server console.
The in-page reset form is not unconditional. The server returns resetLink only when no SMTP host is configured and a developer opted in with ALLOW_PASSWORD_RESET_LINK_IN_RESPONSE=true outside production (resetLinkExposureAllowed() in src/routes/login/auth.remote.ts). Only then does the sign-in view switch to the reset form with a real token; otherwise it keeps the forgot-password form and shows the server’s message (“no email provider is configured — ask an administrator…”).
The reset link is also printed to the server terminal so an admin can share it manually if needed.
B1 (2026-10-31): the reset form must never receive a token on an install where an anonymous visitor could reset the administrator password. SMTP is optional in the setup wizard, so handing the link back by default would be an account-takeover path. Do not relax resetLinkExposureAllowed() to “always”.
SMTP Configuration
To enable email delivery, configure the following keys in System Settings:
| Key | Description | Example |
|---|---|---|
SMTP_HOST |
SMTP server hostname | smtp.gmail.com |
SMTP_PORT |
SMTP server port | 465 (SSL) or 587 (TLS) |
SMTP_USER |
Username for authentication | notifications@yourdomain.com |
SMTP_PASS |
Password for authentication | ************* |
SMTP_MAIL_FROM |
Default “From” email address | SveltyCMS <noreply@yourdomain.com> |
Ensure that your SMTP provider allows connections from your server’s IP address and that any firewall settings permit outgoing traffic on the chosen SMTP port.
Available Templates
| Template | Purpose | Key Props |
|---|---|---|
welcomeUser |
Sent to new signups | username, hostLink |
forgottenPassword |
Password reset link | email, token, resetLink, expiresIn |
updatedPassword |
Password change confirmation | username |
userToken |
User invitation Link | email, role, tokenLink |
databaseFailure |
Critical system alerts | error, metrics, systemState |
customEmail |
Generic notification | body, sitename |
Programmatic Usage
API Endpoint (REST)
You can trigger emails via a standard REST API. This is useful for external services or custom frontend logic.
Endpoint: POST /api/send-mail
Authentication: Requires session or API token.
{
"recipientEmail": "user@example.com",
"subject": "Hello from SveltyCMS",
"templateName": "welcomeUser",
"props": {
"username": "John Doe"
}
}
Automation System Integration
The most common way to send emails is through the GUI Automation System.
- Go to Config > Automations.
- Create a new Automation (e.g., Trigger:
Entry Created). - Add a Send Email operation.
- Use Tokens to dynamically populate fields:
- Recipient:
{{ entry.author_email }} - Body:
Hi {{ entry.author_name }}, your post "{{ entry.title }}" has been published!
- Recipient:
Architecture
graph TD
A["API / automationService"] --> B["email.server.ts (Utility)"]
B --> C["Svelte Compiler (SSR)"]
C --> D["HTML / Text Payload"]
D --> E["Nodemailer Transporter"]
E --> F["SMTP Server"]
subgraph Templates
T1["welcomeUser.svelte"]
T2["forgottenPassword.svelte"]
T3["customEmail.svelte"]
end
C -.->|Import| T1 & T2 & T3
Related Documentation
- Automation System: Learn how to trigger emails based on CMS events.
- Webhook Integrations: For outbound events to third-party services.
- System Settings: Manage SMTP credentials.