Skip to content

SMTP (Nodemailer)

Learn how to set up and use SMTP with Nodemailer for sending emails in your application.

SaasPilot comes configured with Resend by default, but you can easily switch to SMTP using Nodemailer. An email provider is required for essential features such as email verification, password resets, and other transactional emails.

Overview

The SMTP integration uses Nodemailer to send emails through any SMTP server. This gives you flexibility to use services like Gmail, SendGrid, Mailgun, or your own SMTP server.

Setup

1. Choose Your SMTP Provider

Select an SMTP service provider. Popular options include:

  • Gmail: Free for personal use (with app passwords)
  • SendGrid: Generous free tier for transactional emails
  • Mailgun: Good for high-volume sending
  • Amazon SES: Cost-effective for large scale
  • Custom SMTP Server: Use your own mail server

2. Get SMTP Credentials

Obtain the following information from your SMTP provider:

  • Host: SMTP server address (e.g., smtp.gmail.com)
  • Port: Usually 587 (TLS) or 465 (SSL)
  • Username: Your SMTP username or email
  • Password: Your SMTP password or app-specific password

3. Configure Environment Variables

Add your SMTP credentials to your .env file:

txt
EMAIL_SERVER_HOST=""
EMAIL_SERVER_PORT=""
EMAIL_SERVER_USER=""
EMAIL_SERVER_PASSWORD=""
EMAIL_FROM=""

Clean Up Alternative Email Services

If you're using Nodemailer and want to remove the alternative email service files that come with SaasPilot, follow these steps:

1. Delete Unused Service Files

Remove the following folders from your project:

  • lib/resend - Contains Resend configuration
  • lib/mailgun - Contains Mailgun configuration

You can delete these folders manually through your file explorer or code editor.

2. Uninstall Unused Packages

Open your terminal in the project directory and run:

sh
npm uninstall resend mailgun

3. Update Config File

Remove resend and mailgun property from appConfig which is located in config.ts

ts
export const appConfig = {
  // Remove or comment out these
  mailgun: {
    domain: "",
    apiKey: "",
    fromNoReply: ``,
    fromAdmin: ``,
    supportEmail: ""
  },
  resend: {
    resendKey: "",
    fromNoReply: ``,
    fromAdmin: ``,
    supportEmail: ""
  }
};

Built with SaasPilot