带有Gmail“发件人:地址"的Nodemailer不变 [英] Nodemailer with Gmail "From: address" does not change

查看:58
本文介绍了带有Gmail“发件人:地址"的Nodemailer不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向我的邮件列表中的任何新订阅者发送电子邮件.一切工作正常,但是发送者"电子邮件地址不会更改为"noreplay.它保留为我通过身份验证的电子邮件,在这种情况下是我的工作邮件.例如,如果我将"from"设置为"noreply @ example".com"发送来自"jaafar@example.com"的邮件.这是我的代码:

I am trying to send emails to any new subscriber to my mailing list. Everything is working great, but the "sender" email address does not change to "noreplay. It stays as the email I authenticated with, in this case my work mail. For example, if I set the "from" to "noreply@example.com" it sends the mail from "jaafar@example.com". This is my code:

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);
});

我仅以文档中的示例为基础.收到的电子邮件好像来自"JaafarsCompany",但是如果您单击发件人姓名,则会显示我的工作邮件.

I have only built upon the example from the documentation. The received email comes as if it was from "JaafarsCompany", but if you click on the sender-name, it shows my work mail.

希望如此.我正在寻找可以指引我正确方向的任何事物.我觉得我多年来一直在搜索这个问题:(

Hope that makes sense. I am looking for anything that can point me in the right direction. I feel like I have been googling this problem for ages :(

推荐答案

我弄清楚了问题所在.基本上,文档说:

I figured out what the problem was. Essentially the doc says:

Gmail还始终将经过身份验证的用户名设置为发件人:"电子邮件地址.因此,如果您通过foo@example.com进行身份验证并进行设置bar@example.com作为发件人:地址,然后Gmail会将其还原为用已验证的用户替换发件人.

Gmail also always sets authenticated username as the From: email address. So if you authenticate as foo@example.com and set bar@example.com as the from: address, then Gmail reverts this and replaces the sender with the authenticated user.

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

To work around this issue, one needs to add a group in the Admin Console. After that go to this link, and follow the instructions.

我从Firebase支持者那里获得了解决此问题的帮助.希望有一天能对某人有所帮助:-)

I had help from a Firebase Supporter to fix this issue. Hope this helps somebody one day :-)

这篇关于带有Gmail“发件人:地址"的Nodemailer不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆