Skip to content

Instantly share code, notes, and snippets.

@soner8
Created April 9, 2018 15:37
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 soner8/f3c9b02c5fa8aaf1acbfc2d4543c9e23 to your computer and use it in GitHub Desktop.
Save soner8/f3c9b02c5fa8aaf1acbfc2d4543c9e23 to your computer and use it in GitHub Desktop.
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