【发布时间】:2017-08-24 21:54:45
【问题描述】:
我正在尝试使用Nodemailer 发送带有附件的电子邮件。无论我做什么,如果我指定一个attachments 属性,电子邮件就会出现空(没有附件,没有html,没有文本)。发送没有任何附件的电子邮件按预期工作。这是我到目前为止的代码:
transporter.sendMail({
to: `${toTitleCase(i.nome)} <${i.email}>`,
subject: 'Treinamentos',
text: 'hello!',
html: `Embedded image: <img src="cid:nyan@example.com"/>`,
attachments: [
{
filename: 'newimg.jpg',
path: __dirname + '/src/img/newimg.jpg',
cid: 'nyan@example.com'
}
]
}, (err, info )=> {
console.log(err);
console.log(info);
});
我也尝试过使用content 而不是path,结果相同。我还应该注意err 回调是空的。
【问题讨论】:
-
您至少缺少一件事:您的文件中的
contentDisposition: 'inline'。查看我的代码,我还添加了一个密钥:encoding: 'base64'(不确定是否需要) -
@SyedAyeshaBebe 不确定这与我的问题有何关系,因为我什至没有使用 Gmail。无论哪种方式,我都找出了问题所在并将其作为答案提交。
-
我没明白你的意思!!!
标签: javascript node.js email nodemailer