Skip to content

Instantly share code, notes, and snippets.

@cormobro
Last active January 14, 2019 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cormobro/b66c2eb532fa4368a423427c25dce05f to your computer and use it in GitHub Desktop.
Save cormobro/b66c2eb532fa4368a423427c25dce05f to your computer and use it in GitHub Desktop.
send mail
var express = require('express');
var router = express.Router();
const nodemailer = require("nodemailer");
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
router.get('/askForCookiesRecipe', function(req, res, next) {
var smtpTransport = nodemailer.createTransport({
service: "smtp.gmail.com",
auth: {
user: "cormoranger@gmail.com",
pass: "secretsecret"
}
});
smtpTransport.sendMail({
from: "Bonaert Felix <bonaert.felix@gmail.com>", // Expediteur
to: "`supergrandma@yopmail.com", // Destinataires
subject: "DES COOKIES STP", // Sujet
text: "Salut mamy fais moi des cookies j'ai faim", // plaintext body
html: "<b>Salut mamy fais moi des cookies j'ai très faim</b>" // html body
}, (error, response) => {
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
});
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment