-
Notifications
You must be signed in to change notification settings - Fork 25
/
nodeMailer.js
35 lines (30 loc) · 1.1 KB
/
nodeMailer.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
//require nodemailer for sent a mail.
var nodemailer = require('nodemailer');
//we are create a mail transporter which contain services and auth information
var transporter = nodemailer.createTransport({
//service like ghmail,hotmail,yahoo etc...
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'yourpass'
}
});
// we crete a object mailOptions which contains from,to,subject and text
var mailOptions = {
from: '[email protected]',
//we can sent a mail more than one user
//to: '[email protected],[email protected]',
to: '[email protected]',
subject: 'Regarding Attendance review',
//instead of text we are free to write a html
// html : '<h1>Respected sir/mam, your son attendanse in less than 75%</h1>',
text: 'Respected sir/mam, your son attendanse in less than 75%'
};
//we sent a mail using mail transporter if any error then it log errror else it gives a message mail sent.
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});