
/*
 * GET home page.
 */


var nodemailer = require("nodemailer");
var mailCfg = require("../config").mail;
var receiver = require("../config").receiver;

var smtpTransport = nodemailer.createTransport("SMTP",{
   service: "Gmail",
   auth: {
       user: mailCfg.user,
       pass: mailCfg.password
   }
});

exports.index = function(req, res){
  res.render('index', { title: 'Express' });
};

exports.requestPost = function(req, res) {
	var request = {
		name: req.body.name | "",
		email: req.body.email | "",
		message: req.body.message | ""
	};

	res.send(request);

};

exports.send = function(req, res) {
	smtpTransport.sendMail({
	   from: "Arecord.us <nodejs@arecord.us>", // sender address
	   to: receiver,
	   subject: "Hello ✔", // Subject line
	   text: "Hello world ✔" // plaintext body
	}, function(error, response){
	   if(error){
	       console.log(error);
	   }else{
	       console.log("Message sent: " + response.message);
	       res.send(response.message);
	   }
	});
};
@@ -472,16 +472,17 @@
 y.name %7C
+%7C
  %22%22,%0A%09%09e
@@ -503,16 +503,17 @@
 .email %7C
+%7C
  %22%22,%0A%09%09m
@@ -538,16 +538,17 @@
 essage %7C
+%7C
  %22%22%0A%09%7D;%0A
@@ -573,47 +573,184 @@
 );%0A%0A
-%7D;%0A%0Aexports.send = function(req, res) %7B
+%09if (request.email == %22%22) %7B%0A%09%09return res.send(%22Eamil Error%22);%0A%09%7D%0A%0A%09res.send(%22POST success%22);%0A%09var message = request.email + %22%3Cbr/%3E%22 + request.name + %22%3Cbr/%3E%22 + request.message;%0A
 %0A%09sm
@@ -870,77 +870,91 @@
 t: %22
-Hello %E2%9C%94%22, // Subject line%0A%09   text: %22Hello world %E2%9C%94%22 // plaintext body
+%5BArecord.us%5D%22 + request.email + %22send a request%22, // Subject line%0A%09   text: message
 %0A%09%7D,
@@ -1059,72 +1059,8 @@
 log(
-%22Message sent: %22 + response.message);%0A%09       res.send(response.
 mess
@@ -1072,14 +1072,15 @@
 %0A%09   %7D%0A%09%7D);%0A
+%0A
 %7D;

update route