Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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" });
- });
- /* Send mail */
- router.get("/askForCookiesRecipe", function(req, res, next) {
- console.log("hi");
- var transport = nodemailer.createTransport({
- host: "smtp.mailtrap.io",
- port: 2525,
- auth: {
- user: "4df13d539d4b0e",
- pass: "a60dc7d740324d"
- }
- });
- transport.sendMail(
- {
- from: "b9cccc489d-13dec5@inbox.mailtrap.io", // Expediteur
- to: "supergrandma@yopmail.com", // Destinataires
- subject: "Rectte cookies !", // Sujet
- text: "Coucou Mamie, comment vas tu? ✔", // plaintext body
- html:
- "<b>Peux tu me donner ta recette de cookies que j'adore, please! ✔</b>" // html body
- },
- (error, response) => {
- if (error) {
- console.log(error);
- } else {
- console.log("Message sent: " + response.message);
- }
- }
- );
- });
- module.exports = router;
Add Comment
Please, Sign In to add comment