Learn how to set up and use email functionality with Resend and React Email templates
MkSaaS uses Resend for email delivery and React Email for creating beautiful, responsive email templates. This combination provides a modern, developer-friendly way to handle email communications in your application.
Setup
- Create a Resend account at resend.com
- Get your API key with the permissions to send emails from the dashboard
- Add the following environment variables:
- Update the
website.tsx
file to use Resend as the email provider, and set the default sender and recipient email addresse:
If you are setting up the environment, now you can go back to the Environment Setup guide and continue. The rest of this guide can be read later.
Environment Setup
Set up environment variables
Email System Structure
The email system in MkSaaS is designed with the following components:
This modular structure makes it easy to extend the email system with new providers, templates, and components.
Core Features
- Transactional email sending with Resend integration
- Beautiful, responsive email templates built with React Email
- Pre-built templates for verification, password reset, and contact forms
- Internationalization support with multi-language emails
- Reusable email components (layout, buttons, etc.)
- Modular architecture for easy provider switching
- Developer tools for email preview and testing
Usage
MkSaaS provides a simple email sending utility that supports both template-based emails and raw content:
Email Templates
MkSaaS includes several pre-built email templates for different use cases:
Email Components
MkSaaS includes reusable email components in the src/mail/components
directory to help build consistent email templates:
Customization
Creating Custom Templates
- Create a React component in the
src/mail/templates
directory:
- Update the
EmailTemplates
interface intypes.ts
to include your new template:
-
Add corresponding subject translations in your i18n messages if needed
-
Preview your template locally:
- Use the template in your code:
Creating a New Email Provider
MkSaaS makes it easy to extend the email system with new providers:
- Create a new file in the
src/mail/provider
directory - Implement the
MailProvider
interface fromtypes.ts
- Update the provider selection logic in
index.ts
Example implementation for a new provider:
Then update the provider selection in index.ts
:
Best Practices
- Validate Email Addresses: Always validate email addresses before sending emails
- Handle Errors Gracefully: Provide user-friendly error messages when email delivery fails
Next Steps
Now that you understand how to work with emails in MkSaaS, you might want to explore these related features: