-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSendEmail.js
More file actions
38 lines (35 loc) · 1.01 KB
/
SendEmail.js
File metadata and controls
38 lines (35 loc) · 1.01 KB
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
import 'dotenv/config'
import nodemailer from "nodemailer";
const sendEmail = async (to) => {
const transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: process.env.EMAIL_ADDRESS,
pass: process.env.PASSWORD,
},
});
const mailOptions = {
from: `"Abhishek Kumar" <${process.env.EMAIL_ADDRESS}>`,
to,
subject: "Inquiry for Full stack developer",
text: " Hi, Here is my resume, have a good day ✨ !!",
attachments: {
filename: "Full-Stack-dev-Abhishek.pdf",
path: process.env.RESUME,
},
};
return transporter.sendMail(mailOptions);
};
const SendResumeByEmail = async (to) => {
return new Promise(async (resolve, reject) => {
try {
const res = await sendEmail(to);
console.log(res);
resolve(JSON.stringify({ status: "Email has been sent successfully !!" }));
} catch (err) {
console.log(err);
reject(JSON.stringify({ status: "There was some problem" }));
}
});
};
export default SendResumeByEmail;