-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
53 lines (40 loc) · 1.5 KB
/
routes.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
47
48
49
50
51
52
53
module.exports = function(app){
var nodemailer = require("nodemailer");
app.get('/', function(req, res) {
res.render('view.ejs'); // load the view.ejs file
});
// =====================================
// MAIL PAGE ===================
// =============================
// show the mail form
app.get('/view', function(req, res) {
res.render('view.ejs'); // load the view.ejs file
});
// process the email form
app.post('/view', function(req, res){
var firstname =req.body.firstname;
var lastname = req.body.lastname;
var email = req.body.email;
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail", // sets automatically host, port and connection security settings
auth: {
user: "mensonfrancis@gmail.com",
pass: ""
}
});
smtpTransport.sendMail({ //email options
from: "Repositive <----------->", // sender address. Must be the same as authenticated user if using Gmail.
to: ""+firstname+" "+lastname+"<" +email +">", // receiver
subject: "Beta Sign up for Repositive", // subject
text: "MWAHAHAHHAAHHAHAAAHAHHAAHA", // body
html: "<p>hey buddy, well done for signing up! We have a lot of great surprises in store for you<p>"
}, function(error, response){ //callback
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
smtpTransport.close(); // shut down the connection pool, no more messages. Comment this line out to continue sending emails.
});
res.render('done.ejs');
});}