Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express');
- var router = express.Router();
- const nodemailer = require('nodemailer'); // après npm install nodemailer --save nodemailer, il faut déclarer cette variable
- var transport = nodemailer.createTransport({
- host: "smtp.mailtrap.io",
- port: 2525,
- auth: {
- user: "33f63cb5e210d8",
- pass: "edccd63a641240"
- }
- });
- router.get('/askForCookiesRecipe', function(req, res, next) {
- transport.sendMail({
- from: "Gwendoline <gbelnard@gmail.com>", // Expediteur
- to: "supergrandma@yopmail.com", // Destinataires
- subject: "Cookies recipe !", // Sujet
- 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
- }, (error, response) => {
- if(error){
- console.log(error);
- }else{
- console.log("Message sent: " + response.message);
- }
- });
- res.send('votre message a bien été envoyé');
- });
- module.exports = router;
Add Comment
Please, Sign In to add comment