i have a code to send activation link in Server.js....and i want to call it from client side Javascript file ...here is the code
var express=require('express');
var nodemailer = require('nodemailer');
var app=express();
/
Here we are configuring our SMTP Server details.
STMP is mail server which is responsible for sending and recieving email.
/
var smtpTransport = nodemailer.createTransport('SMTP',{
service: 'Gmail',
auth: {
user: '',
pass: ''
}
});
var rand,mailOptions,host,link
app.get('/send',function(req,res){
console.log('Hola!!');
rand=Math.floor((Math.random() * 100) + 54);
host=req.get('host');
link='http://'+req.get('host')+'/verify?id='+rand;
mailOptions={
to : req.query.to,
subject : 'Please confirm your Email account',
html : 'Hello, Please Click on the link to verify your email. Click here to verify'
};
console.log(mailOptions);
smtpTransport.sendMail(mailOptions, function(error, response){
if(error){
console.log(error);
res.end('error');
}else{
console.log('Message sent: ' + response.message);
res.end('sent');
}
});
});
app.get('/verify',function(req,res){
console.log(req.protocol+':/'+req.get('host'));
if((req.protocol+'://'+req.get('host'))===('http://'+host))
{
console.log('Domain is matched. Information is from Authentic email');
if(req.query.id===rand)
{
console.log('email is verified');
res.end('
Email '+mailOptions.email+' is been Successfully verified');
}
else
{
console.log('email is not verified');
res.end('
Bad Request
');
}
}
else
{
res.end('
Request is from unknown source');
}
});
how to route from client side javascript to this server side javascript file
i have a code to send activation link in Server.js....and i want to call it from client side Javascript file ...here is the code
var express=require('express'); var nodemailer = require('nodemailer'); var app=express(); / Here we are configuring our SMTP Server details. STMP is mail server which is responsible for sending and recieving email. / var smtpTransport = nodemailer.createTransport('SMTP',{ service: 'Gmail', auth: { user: '', pass: '' } }); var rand,mailOptions,host,link
app.get('/send',function(req,res){ console.log('Hola!!'); rand=Math.floor((Math.random() * 100) + 54); host=req.get('host'); link='http://'+req.get('host')+'/verify?id='+rand; mailOptions={ to : req.query.to, subject : 'Please confirm your Email account', html : 'Hello,
Please Click on the link to verify your email.
Click here to verify' }; console.log(mailOptions); smtpTransport.sendMail(mailOptions, function(error, response){ if(error){ console.log(error); res.end('error'); }else{ console.log('Message sent: ' + response.message); res.end('sent'); } }); });
app.get('/verify',function(req,res){ console.log(req.protocol+':/'+req.get('host')); if((req.protocol+'://'+req.get('host'))===('http://'+host)) { console.log('Domain is matched. Information is from Authentic email'); if(req.query.id===rand) { console.log('email is verified'); res.end('
Email '+mailOptions.email+' is been Successfully verified'); } else { console.log('email is not verified'); res.end('
Bad Request
'); } } else { res.end('Request is from unknown source'); } });
how to route from client side javascript to this server side javascript file