Blue Flower

1. go to cmd prompt in your root project folder 

   Type npm install nodemailer



2. create mail.js

 

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

var smtpTransport = nodemailer.createTransport(smtpTransport({
    host : "smpt.gmail.com",
    secureConnection : false,
    port: 587,
    auth : {
        user : "
 This email address is being protected from spambots. You need JavaScript enabled to view it.
 ",
        pass : "test123"}
}));
app.get('/send',function(req,res){
    var mailOptions={
        from : "
 This email address is being protected from spambots. You need JavaScript enabled to view it.
 ",
        to : "
 This email address is being protected from spambots. You need JavaScript enabled to view it.
 ",
        subject : "Your Subject",
        text : "Your Text",
        html : "HTML GENERATED",
        /*attachments : [
            {   // file on disk as an attachment                //filename: 'a.txt',path: 'd:/a.txt' // stream this file, use only path property and send the file name in the end, else you may get folder read error}
        ]*/
    }
    console.log(mailOptions);
    smtpTransport.sendMail(mailOptions, function(error, response){
        if(error){
            console.log(error);
            res.end("error");
        }else{
            console.log(response.response.toString());
            console.log("Message sent: " + response.message);
            res.end("sent");
        }
    });
});

app.listen(3000,function(){
    console.log("Express Started on Port 3000");
});
 
 
 
3. Go to command prompt where the mail.js stored
    Type node mail.js
 
 
 
4. open brower
http://localhost:3000/send