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
javascript node.js angular mailgun


source to share


No one has answered this question yet

Check out similar questions:

7728
How do I redirect to another web page?
7649
How does JavaScript blocking work?
7494
How can I remove a specific element from an array in JavaScript?
7432
How to check if a string contains a substring in JavaScript?
7428
How can I check if an element is hidden in jQuery?
5722
How can I remove a property from a JavaScript object?
5129
How do I return a response from an asynchronous call?
4829
How do I include a JavaScript file in another JavaScript file?
2237
How do I pass command line arguments to a Node.js program?
2201
How do you decide when to use Node.js?



All Articles
Loading...
X
Show
Funny
Dev
Pics