How to give notification from nodejs in angular
I used mailgun
to nodejs
to send mail. I can send mail, but I want to confirm that the user has sent mail or not. How to do it from a fileserver.js
app.post( "/home", function( req, res ) {
var api_key = 'key-7a2322746b659a0a26d66f0c07e27db1';
var domain = 'sandbox7102872c028b4e199dcaafbbac291c22.mailgun.org';
var mailgun = require( 'mailgun-js' )( {
apiKey: api_key,
domain: domain
} );
var data = {
from: 'Gundeep <postmaster@sandbox7102872c028b4e199dcaafbbac291c22.mailgun.org>',
to: 'gundeeps2786@gmail.com',
subject: req.body.name,
html: '<b>Client Email Address: </b>' + req.body.email + '<br><b>Subject</b><br>' + req.body.subject +
'<br><b>Message</b><br>' + req.body.message
};
mailgun.messages().send( data, function( error, body ) {
console.log( body );
//var element = document.getElementById("mailSent"); element.innerHTML = "New text!";
if ( !error ) {
res.sendFile( path.join( __dirname, 'index.html' ) );
// alert('hello');
}
// res.send( contact.tpl );
else res.send( "Mail not Send" );
} );
} )
+3
source to share
No one has answered this question yet
Check out similar questions: