Guest User

Untitled

a guest
Jan 14th, 2019
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. const express = require('express');
  2. const router = express.Router();
  3. "use strict";
  4. const nodemailer =require('nodemailer');
  5.  
  6. const smtpTransport = nodemailer.createTransport( {
  7. host: 'smtp.gmail.com',
  8. port: 587,
  9. secure: false,
  10. auth: {
  11. user: "projetpfb@gmail.com",
  12. pass:""
  13. }
  14. });
  15.  
  16. /* GET home page. */
  17. router.get('/', function(req, res, next) {
  18. res.render('index', { title: 'Express' });
  19. });
  20.  
  21. router.use('/superMiddleware', function(req, res, next){
  22. console.log('hello middleware');
  23. next();
  24. }, function (req,res,next) {
  25. res.send('hello world');
  26. next();
  27. });
  28.  
  29. router.use('/askForCookiesRecipe', function(req, res, next){
  30.  
  31. smtpTransport.sendMail({
  32. from:"Deer wild <deer@wild.com>",
  33. to: "supergrandma@yopmail.com",
  34. subject: "Coucou",
  35. text: "Salut Mami c'est quoi la recette des zezettes de Sete? Tu peux l'envoyer? CIMER! ",
  36. html: "<b> Cookie click generator </b>"
  37. }, (error, response) => {
  38. if(error){
  39. console.log(error);
  40. }else{
  41. console.log("Message sent:" + response.response);
  42. }
  43. });
  44. next();
  45. });
  46.  
  47. module.exports = router;
Add Comment
Please, Sign In to add comment