Guest User

Untitled

a guest
May 15th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const nodemailer = require('nodemailer');
  2. process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
  3.  
  4. module.exports = (db, options) => {
  5.   const { logger } = options;
  6.   const transporter = nodemailer.createTransport({
  7.     host: 'ip of instance',
  8.     port: 25,
  9.     secure: false,
  10.     auth: {
  11.       user: '[email protected]',
  12.       pass: 'testPass',
  13.     },
  14.     tls: {
  15.       rejectUnauthorized: false,
  16.     },
  17.   });
  18.  
  19.   return {
  20.     sendEmail,
  21.   };
  22.  
  23.   async function sendEmail(emailTemplate, record, user) {
  24.     const html = textFill(
  25.       emailTemplate.body,
  26.       {
  27.         ...record.body,
  28.         firstname: user.firstName,
  29.       },
  30.     );
  31.  
  32.     const mailOptions = {
  33.        from: '[email protected]',
  34.       to: '[email protected]',
  35.       subject: emailTemplate.title,
  36.       html,
  37.     };
  38.     await transporter.sendMail(mailOptions);
  39.   }
  40. };
Add Comment
Please, Sign In to add comment