码迷,mamicode.com
首页 > 数据库 > 详细

mongodb nodemailer

时间:2018-11-17 16:18:21      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:分享图片   reference   using   err   var   create   func   fun   OAuth2   

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

标签:分享图片   reference   using   err   var   create   func   fun   OAuth2   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!