mongodb nodemailer

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/