2017-02-15 43 views
0

我的目標是從node.js服務器發送一封電子郵件直接用戶的電子郵件,我正在使用Sendgrid發送這些電子郵件。它的工作原理,但問題是,它直接發送到垃圾郵件文件夾。這裏是我從Sendgrid網站複製的代碼Sendgrid node.js直接發送給垃圾郵件

 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); 
     }); 

我有什麼要求完成,以便它直接發送到用戶的收件箱?

回答

相關問題