Guest User

Untitled

a guest
Jun 7th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.03 KB | None | 0 0
  1. router.get('/', function(req, res, next) {
  2. var transporter = nodemailer.createTransport({
  3. service: 'Gmail',
  4. //var info=info.response,
  5. auth: {
  6. user: 'xxxxx', // Your email id
  7. pass: 'xxxxx' // Your password
  8. }//auth
  9. });//transporter=nodemailer.create
  10.  
  11. var mailOptions={
  12. to: 'xxxxxx',
  13. subject: req.body,
  14. //subject: "lt",
  15. text: "Email Test Has Passed"
  16. }//mailOptions
  17.  
  18. transporter.sendMail(mailOptions, function (error, info, callback){
  19. if(error){
  20. console.log(error);
  21. res.json({yo: 'error'});
  22. }else{
  23. console.log('Message sent: ' + info.response);
  24. //console.log('info sent: ' + info);//[obj obj]
  25. infor=info.response;
  26. res.json({yo: info.response});
  27. };//else
  28. });//();//transporter.sendmail(mailoptions)
  29.  
  30. res.render('index', {
  31. title: 'laundrytake: we clean and deliver your laundry/dry cleaning',
  32. page:'Home',
  33. });//atw is a local var inside the temp index feeded from myArtwork
  34. });//router.get(/)
  35.  
  36. router.get('/', function(req, res, next) {
  37. var infor;
  38. var func;
  39. //var func={};
  40. // var p=req.ip;
  41.  
  42. // inside middleware handler
  43. // var ipMiddleware = function(req, res, next) {
  44. // var clientIp = requestIp.getClientIp(req);
  45. // next();
  46. // };
  47. // ipMiddleware;
  48.  
  49. // on localhost you'll see 127.0.0.1 if you're using IPv4
  50. // or ::1, ::ffff:127.0.0.1 if you're using IPv6
  51.  
  52. // app.use(requestIp.mw())
  53.  
  54. // app.use(function(req, res) {
  55. // var ip = req.clientIp;
  56. // res.end(ip);
  57. // });
  58.  
  59. // var ip;
  60. // if (req.headers['x-forwarded-for']) {
  61. // ip = req.headers['x-forwarded-for'].split(",")[0];
  62. // } else if (req.connection && req.connection.remoteAddress) {
  63. // ip = req.connection.remoteAddress;
  64. // } else {
  65. // ip = req.ip;
  66. // }console.log("client IP is *********************" + ip);
  67.  
  68. // var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
  69. // if (ip.substr(0, 7) == "::ffff:") {
  70. // ip = ip.substr(7)
  71. // }
  72. // console.log("client IP is:");
  73. // console.log(ip);
  74.  
  75. var transporter = nodemailer.createTransport({
  76. service: 'Gmail',
  77. //var info=info.response,
  78. auth: {
  79. user: 'xxxxx', // Your email id
  80. pass: 'xxxxx' // Your password
  81. }//auth
  82. });//transporter=nodemailer.create
  83.  
  84. // console.log("xxx");
  85. //var text = 'Hello world from nn' + req.body.name;
  86.  
  87. var mailOptions={
  88. to: 'xxxxxx',
  89. subject: req.body,
  90. //subject: "lt",
  91. text: "Email Test Has Passed"
  92. }//mailOptions
  93.  
  94. transporter.sendMail(mailOptions, function (error, info, callback){
  95. if(error){
  96. console.log(error);
  97. res.json({yo: 'error'});
  98. }else{
  99. console.log('Message sent: ' + info.response);
  100. //console.log('info sent: ' + info);//[obj obj]
  101. infor=info.response;
  102. res.json({yo: info.response});
  103. // app.locals.infor=info.response;
  104. //return(infor, //log infor dnt fix
  105. //console.log("ff"));//ff printout in the end
  106. //callback(infor);//log infor dnt fix //log r [f sendmail]
  107. //return function(){return infor};//log r [f sendmail]. with info involk })(info);info undef, with 3 or () involk tran.sendM(...)not a f
  108. //sign(info.response);//no print out
  109. // return (
  110. // function(){
  111. // //infor=info.response;
  112. // console.log("out :");
  113. // }
  114. // )//}
  115. // func=(function() { //create a new scope using a wrapper function
  116. // var ilocal = info.response; //capture i into a local var
  117. // return function() { //return the inner function
  118. // console.log("My value: " + ilocal);
  119. // };//return f()
  120. // })();//f()
  121. };//else
  122. });//();//transporter.sendmail(mailoptions)
  123.  
  124. //function sign (ff){var xx=ff; console.log(ff);}
  125. // ino=transporter.sendMail();
  126. // ino.out;
  127. //ff //ff() //ff not def return(func ff(){var xx=info.res})
  128. var sign = function( infor ) {//no callback unhandled promise rejec warning no recipients def err
  129. console.log("User: " + infor + " is saved successfully.")
  130. };
  131. var r =transporter.sendMail;//infor: [f: sendMail] undef
  132. //transporter.sendMail( sign );//callback(infor) nothing inside sendMail warning
  133. //transporter.sendMail(mailOptions, sign );//user: null is saved succ
  134. console.log("infor :");
  135. console.log(infor);
  136. console.log(r);
  137. //console.log(info.response);//info not def
  138. //func();//not a f
  139.  
  140. res.render('index', {
  141. title: 'laundrytake: we clean and deliver your laundry/dry cleaning',
  142. page:'Home',
  143. });//atw is a local var inside the temp index feeded from myArtwork
  144. });//router.get(/)
Add Comment
Please, Sign In to add comment