Mailer System
A React-based Markdown editor with TypeScript support, built with shadcn UI and Tailwind CSS.An extendable serverless mailing system with Nextjs and React mail
Overview
The Mail System template provides an extendable, serverless mailing system built with Next.js, TypeScript, and React Mail. It allows you to quickly integrate email sending capabilities into your Next.js application using a zero-config API and customizable email templates.
Features
- Serverless API endpoint for sending emails via
/api/send
. - Environment-based configuration using
.env
files. - Customizable React Mail templates located in the
emails
directory. - Built-in TypeScript types for strong typing and IntelliSense support.
- Deploys seamlessly on Vercel and other serverless platforms.
Prerequisites
- Node.js v120 or newer
- pnpm, npm, or yarn
- A mailing service provider (SMTP, SendGrid, Mailgun, etc.)
Installation
- Clone the repository
- Install dependencies
- Copy environment file
- Configure environment variables
Edit the .env
file at the project root and set your mailing service credentials:
Project Structure
API Endpoint: /api/send
The /api/send
endpoint accepts a POST
request with the following JSON payload:
Example Request
Response
- 200 OK: Email sent successfully.
- 4xx/5xx: Error sending email.
Creating Custom Email Templates
-
Add a new file in
emails/
, e.g.,template_order-confirmation.tsx
. -
Export a React component that returns your email layout:
-
Update your
.env
if needed for new variables. -
Send using the API by setting
template
to your component filename (without extension). -
Other ** Setiing ** can be changed in
project.config.ts
file.
Environment Variables
Name | Description | Required | Default |
---|---|---|---|
SMTP_HOST | SMTP server host (e.g., smtp.gmail.com) | No | ”smtp-relay.sendinblue.com” |
SMTP_PORT | SMTP server port (e.g., 587) | No | 587 |
MAIL_EMAIL | SMTP username/email | Yes | — |
MAIL_PASSWORD | SMTP password | Yes | — |
IDENTITY_KEY | Auth Key | Yes | — |
Deployment
Deploy to Vercel with zero configuration:
- Push your code to GitHub.
- Import the repository in Vercel.
- Set the same environment variables in Vercel Dashboard.
- Deploy! Emails will work out of the box.
Contributing
- Fork the repository.
- Create a new branch:
git checkout -b feature/my-feature
. - Commit your changes:
git commit -m 'Add my feature'
. - Push to the branch:
git push origin feature/my-feature
. - Open a Pull Request.
License
This project is licensed under the MIT License.
Support
For issues and suggestions, please visit the GitHub issues page.