Set up email in your app to send transactional emails like password resets and verification links.
Tools
- Resend: Handles sending transactional emails reliably.
- Vue Email: Creates reusable, styled email templates with Vue components.
Setup
- Sign up at Resend.
- Go to API Keys to create an API Key. Fill in the name you like and keep other options as default. Then click add and copy the API Key .
- Set environment variable:
.env
RESEND_API_KEY="your-resend-api-key" - Go to Domains and add your sending domain (recommended: a subdomain, e.g., resend.yourdomain.com) and complete DNS verification.
- Update your config:
shared/config.ts
email: { senderName: "Your Name from Which App", senderEmail: "no-reply@resend.yourdomain.com", },
Usage
- Send Pre-Configured Emails
Use templates likeforgotPassword,magicLink, orverifyEmail. Example for a password reset email:import { sendEmail } from '~~/server/services/email/send'; await sendEmail({ to: 'someone@email.com', template: 'forgotPassword', params: { name: 'Someone', resetUrl: 'https://your-site.com/reset-password?token=abc', }, locale: 'en', }); - Available Templates:
forgotPassword: For password reset emails.magicLink: For passwordless login links.verifyEmail: For email verification links.accountDeletion: For account deletion confirmation email.waitlistConfirmation: For joining the waitlist email.waitlistNotification: For notify waitlist is over and app is live.
- Customize Templates
Modify templates inserver/services/email/templates/or create new ones by adding toindex.tsand creating a Vue component inserver/services/email/components/. - Styling
Updateserver/services/email/components/emailStyles.tsfor custom email colors and fonts. - Verify Emails
Check sent emails in the Resend Dashboard.