简体   繁体   English

Nodemailer google workspace 在开发中工作,但在生产中将电子邮件 go 发送到垃圾邮件

[英]Nodemailer google workspace works in Dev but in production the emails go to spam

I have a project that sends emails back to people which I deployed on heroku.我有一个项目可以将电子邮件发回给我部署在 heroku 上的人。 The problem is that it works fine in dev but when it has been deployed emails go directly to the spam.问题是它在开发中运行良好,但是当它被部署后,它会直接向垃圾邮件发送电子邮件 go。 What causes this?这是什么原因造成的? Do you need more information from my code to help me?您需要我的代码中的更多信息来帮助我吗?

 const oAuth2Client = new OAuth2(
    MAILING_SERVICE_CLIENT_ID,
    MAILING_SERVICE_CLIENT_SECRET,
    OAUTH_PLAYGROUND
  );
  oAuth2Client.setCredentials({
    refresh_token: MAILING_SERVICE_REFRESH_TOKEN,
  });
  try{

    const  accessToken = await oAuth2Client.getAccessToken();
    
    const transporter = nodemailer.createTransport({
      service: "gmail",
      auth: {
        type: "OAuth2",
        user: SENDER_EMAIL_ADDRESS,
        clientId: MAILING_SERVICE_CLIENT_ID,
        clientSecret: MAILING_SERVICE_CLIENT_SECRET,
        refreshToken: MAILING_SERVICE_REFRESH_TOKEN,
        accessToken,
      },
    });
    await transporter.verify();
    await transporter.sendMail({ from, to, subject, html });
     

///


await sendEmail({
    to: SENDER_EMAIL_ADDRESS,
    subject: subject,
    html: content
});
await sendEmail({
    to: email,
    subject: subject,
    html: `Dear ${firstName},
    <p> Thank you for getting in touch

    </p>
    <p>Best Regards,</p>
    `

If you get something like this "This email has failed its domain's authentication requirements. It may be spoofed or improperly forwarded.".如果您收到类似“此 email 未通过其域的身份验证要求。它可能被欺骗或不正确转发。”。

No, it's nothing that you can do.不,这不是你能做的。 You've probably emailed yourself with fake emails like "test@yahoo.com", try using your real email.您可能已经用“test@yahoo.com”之类的虚假电子邮件向自己发送了电子邮件,请尝试使用您的真实 email。

There is a multiple reasons why this can happen in my case the DKIM of my email api wasn't set up correctly and another things too you can find out the reason why it is not working by using www.mail-tester.com to see the rating of your email and the reasons for it too.在我的情况下发生这种情况的原因有多种,我的 email api 的 DKIM 设置不正确,还有其他事情,您也可以通过使用www.mail-tester.Z4D236D9A2D1ADBECCZFE查看它无法正常工作的原因来查看您的 email 的评级及其原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM