-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.js
More file actions
35 lines (28 loc) · 718 Bytes
/
mail.js
File metadata and controls
35 lines (28 loc) · 718 Bytes
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
26
27
28
29
30
31
32
33
34
35
require('dotenv').config({
path: './config/.env'
})
const nodemailer = require('nodemailer');
const mailGun = require('nodemailer-mailgun-transport');
const auth = {
auth: {
api_key: process.env.API_KEY,
domain: process.env.DOMAIN_KEY
}
};
const transporter = nodemailer.createTransport(mailGun(auth));
const sendMail = (email, subject, text, cb) => {
const mailOptions = {
from: email,
to: 'yemijoshua80@gmail.com',
subject: subject,
text: text
};
transporter.sendMail(mailOptions, (err, data) => {
if(err){
cb(err, null);
} else {
cb(null, data);
}
})
}
module.exports = sendMail;