Tag: 电子邮件附件

我在nodeMailer中的附件path不起作用(Sails应用程序)

我正在使用Sails框架构build一个Web应用程序。 我无法在电子邮件中添加图片。 这是我的邮件选项, var mailOptions = { from: 'mymail@gmail.com', to: to, subject: subject, html: html, attachments: [{ filename: "login-logo.png", filePath: "./assets/images/login-logo.png", cid: "logo-mail" }] }; 和我附上一个图像的我的ejs, <img src="cid:logo-mail" /> 在filePath我尝试 filePath:“./assets/images/login-logo.png” filePath:“/assets/images/login-logo.png” filePath:“/images/login-logo.png” filePath:“./images/login-logo.png” 但没有工作。 我不知道如何解决这个问题。 我真的需要一些帮助。 谢谢。

node.js sendgrid如何附加pdf

我使用sendgrid在我的node.js应用程序中发送电子邮件。 我试图附上一个pdf的每一个组合都以我附加的pdf不可读取而告终。 我试过了: fs.readFile('public_html/img/Report.pdf',function(err,data){ var base64data = new Buffer(data).toString('base64'); sendgrid.send({ to : hexDecode(_.e), from : 'xxxxxxxxx@gmail.com', subject : 'Report', files : [{filename:'Report.pdf',content:'data:application/pdf;base64,'+base64data}], //files : [{filename:'Report.pdf',contentType:'data:application/pdf',url:'public_html/img/'Report.pdf'}], //files : [{filename:'Report.pdf',url:'public_html/img/'Report.pdf'}], html : 'bla bla' 有谁知道如何防止“加载PDF文档失败?

Node.js和Nodemailer:我们可以将PDF文档附加到电子邮件吗?

我想要使​​用nodemailer和node.js附加PDF文档,但是,我发现附件与nodemailer的唯一示例是与.txt文件( 在这里 )。 有谁知道PDF文档附件是否支持nodemailer? 最初它似乎可以附加PDF,但通过电子邮件到达的PDF文件似乎被损坏(见图片)。 代码:(改编自Mahesh的回答) fs.readFile('/filePath/fileName.pdf', function (err, data) { if (err) throw err; var mailOptions = { from: 'Test <formEmail@gmail.com>', // sender address to: 'toPersonName <toEmail@gmail.com>', // list of receivers subject: 'Attachment', // Subject line text: 'Hello world attachment test', // plaintext body html: '<b>Hello world attachment test HTML</b>', // html body attachments: […]