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');
- const transport = nodemailer.createTransport({
- host: "smtp.mailtrap.io",
- port: 2525,
- auth: {
- user: "f1601964ad631d",
- pass: "523592174409c4"
- }
- });
- router.get('/', (req, res, next) => {
- res.render('coucou', { sayHello: 'Hello buddy !' });
- });
- router.post(`/forms-:id(\\d+)`, (req, res, next) => {
- console.log(req.params.id);
- console.log(req.query.level);
- console.log(req.body.name);
- });
- router.get('/askForCookiesRecipe', (req, res, next) => {
- res.render('postpage');
- transport.sendMail({
- from: "sam <tifus69@hotmail.com>", // Expediteur
- to: "supergrandma@yopmail.com", // Destinataires
- subject: "Coucou !", // Sujet
- text: "Hello world ✔", // plaintext body
- html: "<b>Hello world ✔</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