-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmail.js
47 lines (41 loc) · 1.06 KB
/
mail.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
class MailSender{
nodemailer;
gmail;
mailfrom;
tomail;
sub;
message;
constructor(to, sub, msg){
this.mailfrom = '"E-Attendance" <eclassroom1999@gmail.com>';
this.tomail = to;
this.sub = sub;
this.message = msg;
this.nodemailer = require('nodemailer');
this.gmail = this.nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'eclassroom1999@gmail.com',
pass: 'mloquiqighoyiytq'
}
});
console.log('Mail obj created')
}
send(){
console.log("sending mail")
var mailOptions = {
from: this.mailfrom,
to: this.tomail,
subject: this.sub,
html: this.message,
//html: "<b>From Capture It</b>", // html body
};
this.gmail.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
};
}
module.exports = MailSender;