2017-02-15 7 views
0

Mein Ziel ist es, eine E-Mail von Node.js Server direkt Benutzer E-Mail senden, ich benutze Sendgrid diese E-Mail senden. Es funktioniert, aber das Problem ist, es direkt an Spam-Ordner gesendet. Hier ist der Code, den ich von Sendgrid Webseite kopiertSendgrid node.js senden Sie direkt an Spam

 const helper = require('sendgrid').mail; 
     const from_email = new helper.Email("[email protected]"); 
     const to_email = new helper.Email(user.email) 
     const subject = "Reset your password on Hackathon Starter"; 
     const content = new helper.Content("text/plain", `You are receiving this email because you (or someone else) have requested the reset of the password for your account.\n\n 
     Please click on the following link, or paste this into your browser to complete the process:\n\n 
     http://${req.headers.host}/reset/${token}\n\n 
     If you did not request this, please ignore this email and your password will remain unchanged.\n`); 

     const mail = new helper.Mail(from_email, subject, to_email, content); 

     const sg = require('sendgrid')('APIKEY'); 
     const request = sg.emptyRequest({ 
      method: 'POST', 
      path: '/v3/mail/send', 
      body: mail.toJSON() 
     }); 

     sg.API(request, function(error, response) { 
      console.log(response.statusCode); 
      console.log(response.body); 
      console.log(response.headers); 
     }); 

Was sind die Voraussetzungen für mich so zu erfüllen, dass sie direkt an Posteingang des Benutzers senden?

Antwort