nodejs 实现发送邮件功能

const nodemailer = require('nodemailer');

```function senEmail(message) {
    // create reusable transporter object using the default SMTP transport
    let transporter = nodemailer.createTransport({
        host: 'smtp.163.com',
        port: 465,
        secure: true, // secure:true for port 465, secure:false for port 587
        auth: {
            user: '[email protected]',
            pass: 'ljy6585529'
        }
    });
    // setup email data with unicode symbols
    let mailOptions = {
        from: '"iPalmap" ', // sender address
        to: `[email protected]`, // list of receivers
        subject: '定位发生异常', // Subject line
        text: message // plain text body
            // html: '

定位发生异常

' // html body }; // send mail with defined transport object transporter.sendMail(mailOptions, (error, info) => { if (error) { return console.log("---------", error); } // console.log(info) console.log('Message %s sent: %s', info.messageId, info.response); }); }

你可能感兴趣的:(nodejs 实现发送邮件功能)