繁体   English   中英

Nodemailer-如何在Jade中向模板电子邮件添加附件

[英]Nodemailer - how add attachment to template email in jade

我不知道如何利用附件在电子邮件中使用嵌入式图像。

我在.js中:

var mailOptions = { ... html: 'my html jade', attachments: [{ filename: 'image.png', path: '/picture/file', cid: 'myPicture' //same cid value as in the html img src }]

在玉文件中:

... img(src="cid:myPicture")

当我发送我的电子邮件时....这不起作用。 我已经在电子邮件中添加了附件,但是邮件没有嵌入的图像。

哇! 超级老问题。 您已经解决了这个问题,或者现在退出了编程。 当我遇到相同的问题时,Google带领我来到这里。

这一切都归结为道路。 我必须设置包括文件名在内的绝对路径。 因此,在您的情况下,一切都将如下所示:

var mailOptions = {
  // ...
  html: 'my html jade',
  attachments: [{
  filename: 'image.png',
  path: '/picture/file/image.png',
  cid: 'myPicture' //same cid value as in the html img src
}]

我不能说jade ,但是希望这对其他Nodemailer有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM