Skip to content

riccardozambito/nodemailer

Repository files navigation

node-nodemailer

React, Node.js, Express example app to send emails with module Nodemailer using Google standard account / a STMP service. It's configured with webpack, eslint, prettier and babel.

The Examples folder contains the final source code of "Send emails with Node.js module Nodemailer" gist.

Structure

All the source code will be inside src directory. Inside src, there is client and server directories. All the frontend code will be in client directory. Backend Node.js code will be in the server directory.

The React front end includes two simple component: App and Email Form. The call to Node.js backend is done in ../client/services/mailer.js.

The server back-end handles the POST request to send email in ../server/routes/mailer.js. The logic needed to send email with Nodemailer is contained in ../server/service/mailer/mailer.js

Configuration

To can send emails you need to rename config-sample.json to config.json.

{
  "guser": "Your google user",
  "refreshToken": "Google refresh token",
  "smtpServer": "SMTP host server",
  "smtpUser": "SMTP user",
  "smtpPass": "SMTP password"
}

To send emails with your Google account assign real values to guser and refreshToken. Then put downloaded credential JSON into ../server/service/mailer. Rename the JSON to credentials.json.

If you want to use a SMTP service leave blank guser and assign values to smtpServer, smtpUser and smtpPass.

Start

# Start development server 
npm run dev

# Build for production
npm run build

# Start production server
npm start

About

Simple Express and Nodemailer app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published