0
我试图使用Nodemailer发送带附件的电子邮件。不管我做什么,如果我指定一个attachments
属性,电子邮件就会变空(无附件,无html,无文本)。按预期发送没有任何附件的电子邮件。这里是我到目前为止的代码:带附件的邮件在使用Nodemailer时出现空白
transporter.sendMail({
to: `${toTitleCase(i.nome)} <${i.email}>`,
subject: 'Treinamentos',
text: 'hello!',
html: `Embedded image: <img src="cid:[email protected]"/>`,
attachments: [
{
filename: 'newimg.jpg',
path: __dirname + '/src/img/newimg.jpg',
cid: '[email protected]'
}
]
}, (err, info)=> {
console.log(err);
console.log(info);
});
我一直在使用的content
代替path
也试过,相同的结果。我还应该注意,err
回调是空的。
您至少缺少一件东西:'contentDisposition:'inline'' in your file(s)。看一下我的代码,我还添加了一个键:'编码:'base64''(不知道这是否是必需的) – yBrodsky
回复此回答https://stackoverflow.com/a/45388543/7635845 –
@SyedAyeshaBebe不确定这与我的问题有关,因为我甚至没有使用Gmail。无论哪种方式,我找出了什么是错的,并提交它作为答案。 –