-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (33 loc) · 1.2 KB
/
app.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
const nodemailer = require('nodemailer');
const prompt = require('prompt-sync')({sigint: true});
const emailer = async (userEmail, userPass, emailService) => {
let transporter = nodemailer.createTransport({
service: emailService,
auth: {
user: userEmail,
pass: userPass
}
});
const emailTo = prompt("Enter the mail address you want to send email to : ");
const subject = prompt("Enter the Subject of the mail : ");
const text = prompt("Enter the text of the mail : ");
let mailOptions = {
from: userEmail,
to: emailTo,
subject: subject,
text: text
}
await transporter.sendMail(mailOptions, (err, info) => {
if(err) {
console.log(err);
} else {
console.log("Email Sent : " + info.response );
}
})
}
console.log('Welcome To Emailer-JS');
const userEmail = prompt("Enter your Email : ");
const userPass = prompt("Enter your password : ", {echo: '*'});
const emailService = prompt('Enter the name of your email service (eg: gmail)');
console.log(`Your email is ${userEmail}`);
emailer(userEmail, userPass, emailService);