Using Resend
Resend is the recommended email provider for its simplicity and developer experience.Get your API key
Sign up at resend.com and get your API key from the dashboard.
With plain text version
Include a plain text version for better accessibility and spam score:Using SendGrid
SendGrid is a popular enterprise email service.Get your API key
Create an API key in your SendGrid dashboard.
Using Mailgun
Mailgun is another popular email service provider.Using with email preview
ThesendEmail helper works with any provider through custom send functions.
With Resend (default)
src/routes/email-preview/[...email]/+page.server.ts
With custom provider
Custom send function signature
Your custom send function must match this signature:from- Sender email addressto- Recipient email addresssubject- Email subject linehtml- Rendered HTML content
success-trueif email was sent successfullyerror- Error details if sending failed (optional)
SvelteKit form actions
Send emails from SvelteKit form actions:src/routes/signup/+page.server.ts
Tips and best practices
- Use environment variables: Never hardcode API keys in your source code.
- Error handling: Always handle errors gracefully and log them for debugging.
- Plain text versions: Include plain text versions for better deliverability.
- Rate limiting: Implement rate limiting to prevent abuse.
- Testing: Use test mode or sandbox environments during development.
- Monitoring: Set up monitoring to track email delivery and failures.
Next steps
Email Preview
Set up the preview component for development
Testing
Learn how to test your email templates