-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnodeMailer.js
33 lines (29 loc) · 914 Bytes
/
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
// Nodemailes is a module to send mails
// Download using ```npm install nodemailer
var mail = require('nodemailer');
// To send a simple mail
// To send a mail you need some kind of transport
var transport = mail.createTransport({
service: 'gmail', // you mail service provider
auth:{
user: 'email@gmail.com',
pass: 'secret'
}
});
// Now mail structure
var mailStructure = {
from: 'email@gmail.com',
to: 'reciever@anything.com', // For multiple recievers, write the emails comma seperated for the key "to:"
subject: 'Checking Nodemailer',
text: 'You got the meassage?'
// To send html formatted text, even though it has its cons more than pros
html: '<h1>Welcome</h1><p>That was easy!</p>'
};
// Everything is ready, just send the mail
transport.sendMail(function (err, info){
if (err){
console.log('error');
} else {
console.log('Email send: ' + info.response);
}
});