Last active
April 16, 2018 09:54
-
-
Save maylisdoucet/71bd21d948ddf449414e94398d4f93eb to your computer and use it in GitHub Desktop.
emailmamie.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var router = express.Router(); | |
var nodemailer = require("nodemailer"); | |
// Création de la méthode de transport de l'email à intégrer dans index.js dans les routes. | |
var smtpTransport = nodemailer.createTransport({ | |
service: "Gmail", | |
port: 587, | |
auth: { | |
user: "XXX@gmail.com", | |
pass: "XXX" | |
} | |
}); | |
router.get('/askForCookiesRecipe', function(req, res) { | |
smtpTransport.sendMail({ | |
from: "Maylis Doucet <maylis.doucet@gmail.com>", // Expediteur | |
to: "supergrandma@yopmail.com", // Destinataire | |
subject: "Coucou !", // Sujet | |
text: "Hello mamie", // plaintext body | |
html: "<b>Besoin de ta précieuse recette de Cookies.</b>" // html body | |
}, (error, response) => { | |
if(error){ | |
console.log(error); | |
}else{ | |
console.log("Message sent."); | |
} | |
}); | |
}) | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment