-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend.js
30 lines (26 loc) · 975 Bytes
/
send.js
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
var path = require('path')
var bodyParser = require('body-parser')// importing body parser middleware to parse form content from HTML
var nodemailer = require('nodemailer');//importing node mailer
const axios = require('axios');
var nodeoutlook = require('nodejs-nodemailer-outlook');
var auth = require('./config/account.json')
var email = require('./config/email.json')
const sendMail = async (body) => {
// body.author is for backward compatibility
var to = (body.author && body.author.email) || body.to;
var subject = body.subject || email.subject || "Sample Subject";
var message = body.message;
nodeoutlook.sendEmail(
{
...email,
auth: auth,
from: '[email protected]',
to: `${to}`,
subject: `${subject}`,
html: `${message}`,
onError: (e) => console.log(e),
onSuccess: (i) => console.log(i)
}
)
}
module.exports = sendMail