安装模块

npm install -g nodemailer
npm install -g nodemailer-smtp-transport

代码示例


var nodemailer = require('nodemailer') 
var smtpTransport = require('nodemailer-smtp-transport');

smtpTransport = nodemailer.createTransport(smtpTransport({
    host: "smtp.exmail.qq.com",
    port:465,
    auth: {
        user: "xxxx@xxx.com",
        pass: "Sz5M7sfSSSSeCia" //这是邮箱的授权码不是登录密码。 安全登录的客户端专用密码:
    }
}));

var sendMail = function (recipient, subject, html) {

    smtpTransport.sendMail({

        from: "xxx@xxxx.com",
        to: "xxx@xxx.com",
        subject: "代理超时",
        html: "代理错误"

    }, function (error, response) {
        if (error) {
            console.log(error);
        }
        console.log('发送成功')
    });
}

//module.exports = sendMail

sendMail()

相关文章:

  • 2021-06-12
  • 2021-09-18
  • 2021-12-02
  • 2021-12-02
  • 2022-01-03
  • 2021-11-05
  • 2021-07-16
猜你喜欢
  • 2021-07-31
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-12-05
  • 2021-07-02
相关资源
相似解决方案