使用 nodemailer 发送电子邮件时收到 "Gmail couldn't verify that mydomain.com actually sent this message (and not a spammer)" 消息

Getting "Gmail couldn't verify that mydomain.com actually sent this message (and not a spammer)" message when sending emails with nodemailer

我正在尝试使用 nodemailer 发送电子邮件

  let transporter = nodemailer.createTransport({
    host: 'mail.hover.com',
    port: 465,
    secure: true, // true for 465, false for other ports
    auth: {
      user: 'myemail@mydomain.com', 
      pass: 'password', 
    },
  });

  // send mail with defined transport object
  let info = await transporter.sendMail({
    from: {
      name: 'My name',
      address: 'myemail@mydomain.com',
    }, // sender address
    replyTo: 'myemail@mydomain.com',
    to: 'recipient@gmail.com', // list of receivers
    subject: 'Hello ✔', // Subject line
    text: 'Hello world?', // plain text body
    html: '<b>Hello world?</b>', // html body
  });

这会按预期发送电子邮件,但 Gmail 发出警告“Gmail 无法验证 mydomain.com 实际上发送了这封邮件(而不是垃圾邮件发送者)”。我想知道是否有一种方法可以让 Gmail 知道 myemail@mydomain.com 确实发送了电子邮件。

谢谢!

找到解决办法。我基本上允许从我的自定义电子邮件发送电子邮件。我按照这里的指南操作:https://support.google.com/mail/answer/22370?hl=en.

  1. 打开 Gmail。

  2. 在右上角,单击设置设置,然后单击查看所有设置。

  3. 单击“帐户并导入”或“帐户”选项卡。

  4. 在“用这个地址发送邮件”部分,点击添加另一个电子邮件地址。

  5. 输入您的姓名和要发送的地址(我的自定义电子邮件)。

  6. 单击“下一步”,然后单击“发送验证”。

  7. 对于 SMTP 服务器,我输入 mail.hover.com(因为这是我正在使用的)

  8. 登录我的自定义域并点击验证link

  9. 使用 NodeMailer 发送电子邮件

    let transporter = nodemailer.createTransport({
        host: 'smtp.gmail.com',
        port: 465,
        secure: true,
        auth: {
          user: 'mygmailuser@gmail.com', 
          pass: 'password', 
        },
      });
    let info = await transporter.sendMail({
        from: {
          name: 'My name',
          address: 'myemail@mydomain.com',
        },
        to: 'recipient@gmail.com', 
        subject: 'Hello ✔', 
        text: 'Hello world?', 
        html: '<b>Hello world?</b>',
      });