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。無論哪種方式,我找出了什麼是錯的,並提交它作爲答案。 –