带有 Gmail“发件人:地址”的 Nodemailer 不会更改

Jaa*_*hdi 3 node.js firebase nodemailer google-cloud-functions

我正在尝试向我的邮件列表中的任何新订阅者发送电子邮件。一切正常,但“发件人”电子邮件地址不会更改为“noreplay”。它仍然是我进行身份验证的电子邮件,在本例中是我的工作邮件。例如,如果我将“from”设置为“noreply@example” .com”它从“jaafar@example.com”发送邮件。这是我的代码:

if (snapshot.child("subscribed").val() === 'true') {
  var value = snapshot.child("email").val(); //ignore this
  var key = snapshot.key;  //ignore this

  var mailHtml = val.htmlText1 + httpLink + key + val.htmlText2; //ignore this
  let mailOptions = {
   from: '"JaafarsCompany" <noreply@jaafarsCompany.io>', // sender address
   to: value, // list of receivers
   subject: 'Hello', // Subject line
   text: 'Hello world', // plain text body
   html: mailHtml //ignore this
  };

  // send mail with defined transport object
  mailTransport.sendMail(mailOptions, (error, info) => {
   if (error) {
     return console.log(error);
   }
  console.log('Mail sent to: ' + value + '. ' + 'Message %s sent: %s', info.messageId, info.response);
});
Run Code Online (Sandbox Code Playgroud)

我仅基于文档中的示例进行构建。收到的电子邮件看起来像是来自“JaafarsCompany”,但如果您单击发件人姓名,它会显示我的工作邮件。

希望这是有道理的。我正在寻找任何可以为我指明正确方向的东西。我觉得我已经在谷歌上搜索这个问题很多年了:(

Jaa*_*hdi 7

我明白问题出在哪里了。基本上,医生说:

Gmail 还始终将经过身份验证的用户名设置为发件人:电子邮件地址。因此,如果您以 foo@example.com 身份进行身份验证并将 bar@example.com 设置为发件人地址,则 Gmail 会恢复此设置并将发件人替换为经过身份验证的用户。

要解决此问题,需要在管理控制台中添加一个组。之后,转到链接,然后按照说明进行操作。

我得到了 Firebase 支持者的帮助来解决这个问题。希望有一天这对某人有所帮助:-)