【发布时间】:2017-06-26 13:54:51
【问题描述】:
我正在尝试向我的邮件列表中的任何新订阅者发送电子邮件。一切正常,但“发件人”电子邮件地址不会更改为“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);
});
我只是建立在文档中的示例之上。收到的电子邮件好像来自“JaafarsCompany”,但如果您单击发件人名称,它会显示我的工作邮件。
希望这是有道理的。我正在寻找任何可以为我指明正确方向的东西。我觉得我已经在谷歌上搜索这个问题很久了:(
【问题讨论】:
-
所以你上面的代码是可以的......如果不是你应该在你的答案中发布更正的版本
-
代码没问题:-)
标签: node.js firebase google-cloud-functions nodemailer