Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const Fs = require('fs');
- const aws = require('aws-sdk');
- const NodeMailer = require('nodemailer');
- const Ejs = require('ejs');
- // const Parameters = require('../../config/parameters').mail;
- // configure AWS SDK
- aws.config.loadFromPath('./config.json');
- // create Nodemailer SES transporter
- let transporter = nodemailer.createTransport({
- SES: new aws.SES({
- apiVersion: '2017-2-17'
- })
- });
- // const gmailTransport = NodeMailer.createTransport({
- // host: 'smtp.gmail.com',
- // port: 465,
- // auth: {
- // user: process.env.MAIL_USERNAME,
- // pass: process.env.MAIL_PASSWORD
- // }
- // });
- // exports.getMailTemplate = (path) => {
- // return Fs.readFileSync(path, 'utf8');
- // };
- // exports.sendHtmlEmail = (subject, templateFile, email, datas) => {
- // let template = Ejs.compile(templateFile.toString());
- // let mailOptions = {
- // from: process.env.MAIL_EMAIL,
- // to: email,
- // subject: subject,
- // html: template(datas)
- // };
- // gmailTransport.sendMail(mailOptions, (err, res) => {
- // if (err) {
- // throw err;
- // }
- // gmailTransport.close();
- // });
- // };
- exports.sendHtmlEmail = (subject, email) => {
- transporter.sendMail({
- from: 'noreply.prayforhana@gmail.com',
- to: email,
- subject: subject,
- text: 'I hope this message gets sent!',
- // ses: { // optional extra arguments for SendRawEmail
- // Tags: [{
- // Name: 'tag name',
- // Value: 'tag value'
- // }]
- // }
- }, (err, info) => {
- console.log(info.envelope);
- console.log(info.messageId);
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement