Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- router.get('/', function(req, res, next) {
- var transporter = nodemailer.createTransport({
- service: 'Gmail',
- //var info=info.response,
- auth: {
- user: 'xxxxx', // Your email id
- pass: 'xxxxx' // Your password
- }//auth
- });//transporter=nodemailer.create
- var mailOptions={
- to: 'xxxxxx',
- subject: req.body,
- //subject: "lt",
- text: "Email Test Has Passed"
- }//mailOptions
- transporter.sendMail(mailOptions, function (error, info, callback){
- if(error){
- console.log(error);
- res.json({yo: 'error'});
- }else{
- console.log('Message sent: ' + info.response);
- //console.log('info sent: ' + info);//[obj obj]
- infor=info.response;
- res.json({yo: info.response});
- };//else
- });//();//transporter.sendmail(mailoptions)
- res.render('index', {
- title: 'laundrytake: we clean and deliver your laundry/dry cleaning',
- page:'Home',
- });//atw is a local var inside the temp index feeded from myArtwork
- });//router.get(/)
- router.get('/', function(req, res, next) {
- var infor;
- var func;
- //var func={};
- // var p=req.ip;
- // inside middleware handler
- // var ipMiddleware = function(req, res, next) {
- // var clientIp = requestIp.getClientIp(req);
- // next();
- // };
- // ipMiddleware;
- // on localhost you'll see 127.0.0.1 if you're using IPv4
- // or ::1, ::ffff:127.0.0.1 if you're using IPv6
- // app.use(requestIp.mw())
- // app.use(function(req, res) {
- // var ip = req.clientIp;
- // res.end(ip);
- // });
- // var ip;
- // if (req.headers['x-forwarded-for']) {
- // ip = req.headers['x-forwarded-for'].split(",")[0];
- // } else if (req.connection && req.connection.remoteAddress) {
- // ip = req.connection.remoteAddress;
- // } else {
- // ip = req.ip;
- // }console.log("client IP is *********************" + ip);
- // var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
- // if (ip.substr(0, 7) == "::ffff:") {
- // ip = ip.substr(7)
- // }
- // console.log("client IP is:");
- // console.log(ip);
- var transporter = nodemailer.createTransport({
- service: 'Gmail',
- //var info=info.response,
- auth: {
- user: 'xxxxx', // Your email id
- pass: 'xxxxx' // Your password
- }//auth
- });//transporter=nodemailer.create
- // console.log("xxx");
- //var text = 'Hello world from nn' + req.body.name;
- var mailOptions={
- to: 'xxxxxx',
- subject: req.body,
- //subject: "lt",
- text: "Email Test Has Passed"
- }//mailOptions
- transporter.sendMail(mailOptions, function (error, info, callback){
- if(error){
- console.log(error);
- res.json({yo: 'error'});
- }else{
- console.log('Message sent: ' + info.response);
- //console.log('info sent: ' + info);//[obj obj]
- infor=info.response;
- res.json({yo: info.response});
- // app.locals.infor=info.response;
- //return(infor, //log infor dnt fix
- //console.log("ff"));//ff printout in the end
- //callback(infor);//log infor dnt fix //log r [f sendmail]
- //return function(){return infor};//log r [f sendmail]. with info involk })(info);info undef, with 3 or () involk tran.sendM(...)not a f
- //sign(info.response);//no print out
- // return (
- // function(){
- // //infor=info.response;
- // console.log("out :");
- // }
- // )//}
- // func=(function() { //create a new scope using a wrapper function
- // var ilocal = info.response; //capture i into a local var
- // return function() { //return the inner function
- // console.log("My value: " + ilocal);
- // };//return f()
- // })();//f()
- };//else
- });//();//transporter.sendmail(mailoptions)
- //function sign (ff){var xx=ff; console.log(ff);}
- // ino=transporter.sendMail();
- // ino.out;
- //ff //ff() //ff not def return(func ff(){var xx=info.res})
- var sign = function( infor ) {//no callback unhandled promise rejec warning no recipients def err
- console.log("User: " + infor + " is saved successfully.")
- };
- var r =transporter.sendMail;//infor: [f: sendMail] undef
- //transporter.sendMail( sign );//callback(infor) nothing inside sendMail warning
- //transporter.sendMail(mailOptions, sign );//user: null is saved succ
- console.log("infor :");
- console.log(infor);
- console.log(r);
- //console.log(info.response);//info not def
- //func();//not a f
- res.render('index', {
- title: 'laundrytake: we clean and deliver your laundry/dry cleaning',
- page:'Home',
- });//atw is a local var inside the temp index feeded from myArtwork
- });//router.get(/)
Add Comment
Please, Sign In to add comment