Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const router = express.Router();
- const nodemailer = require('nodemailer');
- router.post('/', (req, res, next) => {
- // Création de la méthode de transport de l'email
- let transport = nodemailer.createTransport({
- host: 'smtp.mailtrap.io',
- port: 2525,
- auth: {
- user: 'f1b80fb5967bef',
- pass: '5a7571368a136e'
- }
- });
- const mailOptions = {
- from: '"Test Server" <test@example.com>',
- to: req.body.email,
- subject: 'Cookies',
- text: 'Mamie, balance la recette des cookies'
- };
- transport.sendMail(mailOptions, (err, info) => {
- if (err) {
- console.log(err);
- return next(err);
- }
- console.log('Info: ', info);
- res.json({
- message: 'Email successfully sent.'
- });
- });
- });
- module.exports = router;
Add Comment
Please, Sign In to add comment