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