Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // on importe le module express
- const express = require('express')
- const router = express.Router();
- const nodemailer = require('nodemailer')
- // Création de la méthode de transport de l'email
- let transporter = nodemailer.createTransport({
- host: 'smtp.gmail.com',
- port: 587,
- secure: false, // true for 465, false for other ports
- auth: {
- user: 'coucou@gmail.com', // generated ethereal user
- pass: 'motdepasse' // generated ethereal password
- }
- })
- router.get('/', (req, res) => {
- transporter.sendMail({
- from: "Deer Wild <deer@wild.com>", // Expediteur
- to: "supergrandma@yopmail.com, sophie.michaudel@gmail.com", // Destinataires
- subject: "Coucou mémé !", // Sujet
- text: "J'ai bien aimé tes cookies aux herbes la dernière fois, aurais-tu une recette ?", // plaintext body
- html: "<b>J'ai bien aimé tes cookies aux herbes la dernière fois, aurais-tu une recette ?</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