“This article is participating in the technical topic essay node.js advanced road, click to see details”

Node.js uses Nodemailer to send email notifications

Nodemailer is a module for Node.js applications that makes it easy to send E-mail. Supports Windows, node.js v6.0.0 or later is required.

Install Nodemailer

yarn add nodemailer 
or
npm i nodemailer
Copy the code

use

Here use QQ mailbox to send mail, open SMTP tutorial

const nodemailer = require('nodemailer'); / / 1. Create a Nodemailer SMTP transfer objects from = Nodemailer. CreateTransport ({host: 'smtp.qq.com', the port: '465', secureConnection: true, Secure: false, // true for 465, false for other ports auth: {user:'SMTP mailbox name ', pass: 'SMTP authorization code '}}); Const data = {subject: 'title ', from:' send email 'to:' send email ', HTML: 'support sending EMAIL ', text:' text content '} // 3. Sent from the sendMail (data)Copy the code

For more information, please refer to the documentation

reference

Github.com/nodemailer/…

My blog and GitHub address

github.com/lanpangzhi

blog.langpz.com