Guest User

Untitled

a guest
Oct 25th, 2017
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. var express = require('express');
  2. var router = express.Router();
  3. const nodemailer = require('nodemailer'); // après npm install nodemailer --save nodemailer, il faut déclarer cette variable
  4.  
  5. var transport = nodemailer.createTransport({
  6. host: "smtp.mailtrap.io",
  7. port: 2525,
  8. auth: {
  9. user: "33f63cb5e210d8",
  10. pass: "edccd63a641240"
  11. }
  12. });
  13.  
  14. router.get('/askForCookiesRecipe', function(req, res, next) {
  15. transport.sendMail({
  16. from: "Gwendoline <gbelnard@gmail.com>", // Expediteur
  17. to: "supergrandma@yopmail.com", // Destinataires
  18. subject: "Cookies recipe !", // Sujet
  19. text: "Hello grandmother! I would like to make cookies but I want to be sure to eat the best in the world! Can you please send me your superb recipe? Kisses, Gwendoline", // plaintext body
  20. }, (error, response) => {
  21. if(error){
  22. console.log(error);
  23. }else{
  24. console.log("Message sent: " + response.message);
  25. }
  26. });
  27. res.send('votre message a bien été envoyé');
  28. });
  29.  
  30. module.exports = router;
Add Comment
Please, Sign In to add comment