Last active
January 14, 2019 09:20
-
-
Save cormobro/b66c2eb532fa4368a423427c25dce05f to your computer and use it in GitHub Desktop.
send mail
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(); | |
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