-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (42 loc) · 1.23 KB
/
app.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const express = require('express')
const nodemailer = require('nodemailer')
var bodyParser = require('body-parser')
const app = express();
const port = 4444
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(bodyParser.json());
app.post('/send-emails', (req, res)=>{
const emailAddresses = req.body.emailAddresses;
const toMails = emailAddresses.join(', ')
const transporter = nodemailer.createTransport({
service:'hotmail',
auth:{
user:'[email protected]',
pass:'m%Ix*LX82^2z',
},
tls: {rejectUnauthorized: false}
})
const mailOptions = {
from:'[email protected]',
to:toMails,
subject: 'Looking For Blood Donors',
text: `
Hello user!
The blood bank of SmartCare Hospitals is running short of blood of your type, and is actively looking for donors.
If you're interested in donating blood, please contact the hospital by contacting (+94)112345678.
Thank You!
`
}
transporter.sendMail(mailOptions, (err, info)=>{
if(err) {
console.log(err)
}
console.log('Emails Sent!')
})
res.send('Emails sent successfully');
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})