summaryrefslogtreecommitdiffstats
path: root/helpers/sendMail.js
blob: 6e3a370688d832b27e976c6ae6430bc3a4ef3889 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const mailer = require('nodemailer')

const sendMail = ({to, subject, text, html}) => {
  const transporter = mailer.createTransport({
    port: 465,
    host: process.env.MAIL_SMTP_SERVER,
    auth: {
      user: process.env.MAIL_ADDRESS,
      pass: process.env.MAIL_PASSWORD
    },
    secure: true
  })

  const mailData = {
    from: `"Pruss.it" <${process.env.MAIL_ADDRESS}>`,
    to,
    subject,
    text,
    html
  }

  return transporter.sendMail(mailData)
}

module.exports = sendMail