Sendgrid node.js直接发送到垃圾邮件

Sendgrid node.js直接发送到垃圾邮件,node.js,email,sendgrid,Node.js,Email,Sendgrid,我的目标是直接从node.js服务器向用户的电子邮件发送电子邮件,我使用Sendgrid发送这些电子邮件。它可以工作,但问题是,它直接发送到垃圾邮件文件夹。这是我从Sendgrid网站复制的代码 const helper = require('sendgrid').mail; const from_email = new helper.Email("testing2@gmail.com"); const to_email = new helper.

我的目标是直接从node.js服务器向用户的电子邮件发送电子邮件,我使用Sendgrid发送这些电子邮件。它可以工作,但问题是,它直接发送到垃圾邮件文件夹。这是我从Sendgrid网站复制的代码

        const helper = require('sendgrid').mail;
        const from_email = new helper.Email("testing2@gmail.com");
        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);
        });

我需要满足哪些要求才能将其直接发送到用户的收件箱?

我不认为这个问题来自您的代码本身。如果邮件已到达预期的收件箱(即使在垃圾邮件文件夹中),则您的代码正常。它可以来自各种设置,我建议您阅读sendgrid的这篇vblog文章:

我不认为这个问题来自您的代码本身。如果邮件已到达预期的收件箱(即使在垃圾邮件文件夹中),则您的代码正常。它可以来自各种设置,我建议您阅读来自sendgrid的这篇vblog文章:

在我的情况下,我的电子邮件被标记为垃圾邮件,因为锚标签与实际调用的href不同。 这是因为sendgrid的“单击跟踪”设置

所以,如果你有

<a href="http://yourdomain.com">yourdomain.com</a>

sendgrid可能会替换href,您最终会得到如下结果:

<a href="http://sendgrid.net/....<very-long-url>.......">yourdomain.com</a>

正在调用的sendgrid页面跟踪单击,然后将用户重定向到最初设置的url。但这有时会导致您的电子邮件被标记为垃圾邮件

尝试将sendgrid仪表板中的“单击跟踪”设置为关闭:设置|跟踪|单击跟踪


此处的详细信息:

在我的情况下,我的电子邮件被标记为垃圾邮件,因为锚标签与实际调用的href不同。 这是因为sendgrid的“单击跟踪”设置

所以,如果你有

<a href="http://yourdomain.com">yourdomain.com</a>

sendgrid可能会替换href,您最终会得到如下结果:

<a href="http://sendgrid.net/....<very-long-url>.......">yourdomain.com</a>

正在调用的sendgrid页面跟踪单击,然后将用户重定向到最初设置的url。但这有时会导致您的电子邮件被标记为垃圾邮件

尝试将sendgrid仪表板中的“单击跟踪”设置为关闭:设置|跟踪|单击跟踪

详情如下: