Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 带Gmail的nodeEmailer“;发件人:地址;不变_Node.js_Firebase_Google Cloud Functions_Nodemailer - Fatal编程技术网

Node.js 带Gmail的nodeEmailer“;发件人:地址;不变

Node.js 带Gmail的nodeEmailer“;发件人:地址;不变,node.js,firebase,google-cloud-functions,nodemailer,Node.js,Firebase,Google Cloud Functions,Nodemailer,我正在尝试向我的邮件列表中的任何新订户发送电子邮件。一切都很正常,但“发件人”电子邮件地址不会更改为“noreplay”。它将保留为我通过身份验证的电子邮件,在本例中为我的工作邮件。例如,如果我将“发件人”设置为noreply@example.com“它从发送邮件”jaafar@example.com“。这是我的密码: if (snapshot.child("subscribed").val() === 'true') { var value = snapshot.child("email"

我正在尝试向我的邮件列表中的任何新订户发送电子邮件。一切都很正常,但“发件人”电子邮件地址不会更改为“noreplay”。它将保留为我通过身份验证的电子邮件,在本例中为我的工作邮件。例如,如果我将“发件人”设置为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);
});
if(snapshot.child(“subscribed”).val()='true'){
var value=snapshot.child(“email”).val();//忽略此选项
var key=snapshot.key;//忽略此选项
var mailHtml=val.htmlText1+httpLink+key+val.htmlText2;//忽略此项
让邮件选项={
发件人:“'JaafarsCompany',//发件人地址
to:value,//接收者列表
主题://你好,//主题行
text:'Hello world',//纯文本正文
html:mailHtml//忽略此
};
//使用定义的传输对象发送邮件
mailTransport.sendMail(mailpoptions,(错误,信息)=>{
如果(错误){
返回console.log(错误);
}
console.log('Mail sent to:'+value+'.+'Message%s sent:%s',info.messageId,info.response);
});
我只是以文档中的示例为基础。收到的电子邮件就像来自“JaafarsCompany”,但如果单击发件人名称,它会显示我的工作邮件


希望这是有意义的。我正在寻找任何能为我指明正确方向的东西。我觉得我已经在谷歌上搜索这个问题很久了:(

我找到了问题所在。基本上,医生说:

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

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


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

所以你上面的代码是正确的…如果没有,你应该在你的回答中发布正确的版本代码是正确的:-)你的答案没有被我清除。我也有同样的问题。但是在我的情况下“从“地址会根据用户从数据库收到的电子邮件动态变化。在这种情况下,解决方案可能是什么。嗯,很抱歉,我不知道解决方案可能是什么。在我的情况下,“发件人”邮件是我自己发的,好像我发送了个人邮件,但事实并非如此,所以我想将其更改为“否”-reply@xxxxxx.com"你的回答对你自己的问题无效。你没有包括gmail只允许最多99封电子邮件这一事实。那么,如果有一百万个地址从gmail发送呢?