-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmailer.js
More file actions
36 lines (31 loc) · 1.11 KB
/
mailer.js
File metadata and controls
36 lines (31 loc) · 1.11 KB
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
var nodemailer = require("nodemailer");
module.exports = function(options, callback) {
if (!options.name) throw new Error('options.name is required');
if (!options.email) throw new Error('options.email is required');
if (!options.message) throw new Error('options.message is required');
var name = options.name;
var email = options.email;
var message = options.message;
// create reusable transport method (opens pool of SMTP connections)
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "hotmail",
auth: {
user: 'contact@csunplugged.org.il',
// pass: process.env.EMAIL_PASS,
pass: 'HellYeahComputer',
}
});
// setup e-mail data with unicode symbols
var mailOptions = {
from: name + "<" + email + ">",
replyTo: email,
to: "contact@csunplugged.org.il",
subject: "New message from website",
text: message,
};
// send mail with defined transport object
smtpTransport.sendMail(mailOptions, function(error, response){
smtpTransport.close(); // shut down the connection pool, no more messages
return callback(error, response);
});
};