【问题标题】:Sendgrid node.js send directly to spamSendgrid node.js 直接发送到垃圾邮件
【发布时间】:2017-02-15 08:58:11
【问题描述】:

我的目标是从 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);
        });

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

【问题讨论】:

    标签: node.js email sendgrid


    【解决方案1】:

    我不认为这个问题来自您的代码本身。如果邮件已到达预期的收件箱(即使在垃圾邮件文件夹中),您的代码也可以。它可以来自各种设置,我建议您阅读 sendgrid 的这篇 vblog 帖子:https://sendgrid.com/blog/10-tips-to-keep-email-out-of-the-spam-folder/

    【讨论】:

      【解决方案2】:

      在我的情况下,我的电子邮件被标记为垃圾邮件,因为锚标签与实际调用的 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 仪表板中的“点击跟踪”设置为关闭:设置 |跟踪 |点击跟踪。

      详情在这里:https://sendgrid.com/docs/ui/account-and-settings/tracking/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-12
        • 2012-09-21
        • 1970-01-01
        • 2012-07-21
        • 2013-10-17
        • 2013-05-19
        • 2015-05-01
        • 2012-05-27
        相关资源
        最近更新 更多