-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
48 lines (43 loc) · 1.2 KB
/
index.ts
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
import * as nodemailer from "nodemailer";
require('dotenv').config()
const mailSettings = {
host: process.env.HOST,
port: +process.env.PORT!,
secure: process.env.SECURE === 'true',
user: process.env.USERMAIL,
pass: process.env.PASS,
bcc: process.env.BCC!,
from: process.env.FROM,
to: process.env.TO,
subject: process.env.SUBJECT,
html: process.env.HTML,
}
console.log(mailSettings)
const mailer = async () => {
let transporter = nodemailer.createTransport({
host: mailSettings.host,
port: mailSettings.port,
secure: mailSettings.secure, // true for 465, false for other ports
auth: {
user: mailSettings.user,
pass: mailSettings.pass,
},
tls: {
rejectUnauthorized: false
},
});
try {
await transporter.sendMail({
bcc: [mailSettings.bcc],
from: mailSettings.from,
to: mailSettings.to,
subject: mailSettings.subject,
html: mailSettings.html
});
console.log('Mail Sent')
} catch (e) {
console.info('MAIL SEND ERROR', e?.toString())
console.info(e)
}
}
mailer().then(r => r)