-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSendEmail.js
42 lines (40 loc) · 1.14 KB
/
SendEmail.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
"use strict";
// const nodemailer = require("nodemailer");
import nodemailer from "nodemailer";
const SendResumeByEmail = async (to, from) => {
return new Promise(async (resolve, reject) => {
const transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
service: "gmail",
secure: true,
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,
},
};
transporter
.sendMail(mailOptions)
.then((res) => {
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;