Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
mail.js
var express = require('express');
var router = express.Router();
var cookieParser = require('cookie-parser');
var session = require('express-session');
var app = express();
const nodemailer = require("nodemailer");
var smtpTransport = require('nodemailer-smtp-transport');
var transport = nodemailer.createTransport(smtpTransport({
service: 'gmail',
auth: {
user: 'maco@gmail.com', // my mail
pass: 'monMDP' // t'auras pas mon MDP coco !
}
}));
/* GET home page. */
router.get('/', function (req, res) {
res.render('index', {
title: 'Express'
});
});
router.get('/askForCookieRecipe', function (req, res) {
transport.sendMail({
from: " <runthecity8@gmail.com>", // Expediteur
to: "maco.dou@hotmail.com", // Destinataires
subject: "Coucou !", // Sujet
text: "Hello Mamie, j'ai besoin de ta méga recette pour tes mégas Cookies ! Hell Yeah !", // plaintext body
html: "<b>Hello Mamie, j'ai besoin de ta méga recette pour tes mégas Cookies ! Hell Yeah !</b>" // html body
}, (error, response) => {
if (error) {
console.log(error);
} else {
console.log("Message sent: " + response.message);
}
});
res.end();
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment