-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (60 loc) · 1.77 KB
/
index.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
const express = require('express');
const http = require('http');
const dotenv = require('dotenv');
const nodemailer = require('nodemailer');
// TODO: initialize server using express
dotenv.config()
const PORT = process.env.PORT || 4564;
const app = express();
const server = http.createServer(app);
/* TODO: index routing and middleware */
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
/* TODO: add mailserver */
const transporterGmail = nodemailer.createTransport({
service: 'gmail',
auth: {
user: `${process.env.GOOGLE_ACCOUNT}`,
pass: `${process.env.GOOGLE_PASSWORD}`,
},
});
const transporterOutlook = nodemailer.createTransport({
host: 'smtp.office365.com',
port: 587,
secure: false,
auth: {
user: `${process.env.OUTLOOK_ACCOUNT}`,
pass: `${process.env.OUTLOOK_PASSWORD}`,
},
});
/* TODO: setting email */
const mailOptions = {
from: 'romi.julianto@elnusa.co.id',
to: 'yuulistina@gmail.com',
subject: 'Subject of your email',
html: '<div>tes</div>',
attachments: [
{
filename: 'CV dan Portofolio.pdf',
path: 'src/document/CV and Portofolio_Romi Julianto_Data Analyst-1.pdf',
encoding: 'base64',
},
],
};
transporterGmail.sendMail(mailOptions, (error, info) => {
if (error) {
console.error('Error sending email:', error);
} else {
console.log('Email sent:', info.response);
}
});
transporterOutlook.sendMail(mailOptions, (error, info) => {
if (error) {
console.error('Error sending email:', error);
} else {
console.log('Email sent:', info.response);
}
});
server.listen(PORT, () => {
console.log('Server Email SPBU Checking Pertamina listen', `http://localhost:${PORT}`);
});