首页 > 数据库技术 > 详细

mongodb nodemailer

时间:2018-11-17 15:40:13      阅读:184      评论:0      收藏:0      [点我收藏+]
npm i --save nodemailer


var nodemailer = require("nodemailer");


app.get("/sendEmail",function(req,res){
    var mailTrans = nodemailer.createTransport({
        service:‘Gmail‘,
        auth:{
            user:‘xxx@gmail.com‘,
            pass:xxx
        },
        port:587,
        secure: false,
        tls:{
            rejectUnauthorized:false
        }
    });
    mailTrans.sendMail({
        from:‘xx@163.com‘,
        to:‘xxx@163.com‘,
        subject:‘my subject is here‘,
        text:‘thank your for your letter !‘
    },function(err){
        if(err) console.log(‘unabled to send email‘+err);
    });
    res.json({code:0})
})

question:
技术分享图片

技术分享图片

Reference:
https://stackoverflow.com/questions/31473292/etimedout-connect-error-using-nodemailer-in-nodejs-openshift-application
http://masashi-k.blogspot.com/2013/06/sending-mail-with-gmail-using-xoauth2.html
https://nodemailer.com/about/

mongodb nodemailer

原文:https://www.cnblogs.com/cyany/p/9973791.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!