Guest User

Untitled

a guest
Jan 7th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. var express = require('express');
  2. var router = express.Router();
  3. const nodemailer = require("nodemailer");
  4.  
  5. var smtpTransport = nodemailer.createTransport({
  6. host: 'smtp.gmail.com',
  7. port: 587,
  8. secure: false,
  9. auth: {
  10. user: "projetpfb@gmail.com",
  11. pass: "jecode4wcs"
  12. }
  13. });
  14. // Création de la méthode de transport de l'email
  15.  
  16. /* GET users listing. */
  17. router.get('/', function (req, res, next) {
  18. res.send('Hey ! It\'s a GET');
  19. });
  20.  
  21. router.get('/askForCookiesRecipe', function(req, res, next){
  22. smtpTransport.sendMail({
  23. from: "Deer Wild <projetpfb@gmail.com>", // Expediteur
  24. to: "supergrandma@yopmail.com", // Destinataires
  25. subject: "Coucou grand-mère!", // Sujet
  26. text: "Hello Grand-mère ✔", // plaintext body
  27. html: "<b>J'aurais besoin de ta recette de cookies. Tu peux me la partager s'il te plaît ? Merci et Gros bisous grand-mère!</b>" // html body
  28. }, (error, response) => {
  29. if (error) {
  30. console.log(error);
  31. } else {
  32. console.log("Message sent: ", response.response);
  33. }
  34. });
  35. })
  36.  
  37. module.exports = router;
Add Comment
Please, Sign In to add comment