-
Notifications
You must be signed in to change notification settings - Fork 2
/
email.js
71 lines (63 loc) · 1.88 KB
/
email.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const nodemailer = require('nodemailer')
require('dotenv').config()
const sendEmail = async (email, subject, text) => {
try {
let host, username, password, port
switch (process.env.EVENT) {
case "Meta":
console.log("Sending email to "+ email + " for event " + process.env.EVENT)
host = "server193.iseencloud.com"
port = 465
username = "meta@wcewlug.org"
password = "eventemail@wcewlug"
break;
case "LinuxDiary":
console.log("Sending email to "+ email + " for event " + process.env.EVENT)
host = "server193.iseencloud.com"
port = 465
username = "linuxdiary@wcewlug.org"
password = "eventemail@wcewlug"
break;
case "OSD":
console.log("Sending email to "+ email + " for event " + process.env.EVENT)
host = "server193.iseencloud.com"
port = 465
username = "linuxdiary@wcewlug.org"
password = "eventemail@wcewlug"
break;
case "TechnoTweet":
console.log("Sending email to "+ email + " for event " + process.env.EVENT)
host = "server193.iseencloud.com"
port = 465
username = "technotweet@wcewlug.org"
password = "eventemail@wcewlug"
break;
default:
host = "server193.iseencloud.com"
port = 465
username = "tux@wcewlug.org"
password = "eventemail@wcewlug"
break;
}
let transporter = nodemailer.createTransport({
host: host,
port: port,
secure: true,
auth: {
user: username,
pass: password,
},
});
await transporter.sendMail({
from: `WLUG <${username}>`,
to: email,
subject: subject,
html: text,
});
console.log("Email Sent Sucessfully");
} catch (error) {
console.log("Email Not Sent");
console.log(error);
}
};
module.exports = sendEmail