nodemailer发送空文件?

时间:2018-07-11 23:34:35

标签: javascript node.js nodemailer

我编写了一个脚本,用于从表单发送带有附件的电子邮件,但是邮件发送的是空附件而不是原始文档,并且在尝试访问路径iam时出现以下错误:-

错误:EISDIR:对目录的非法操作,读取错误号:-4068,代码:'ESTREAM',系统调用:'read',命令:'API'

这是我的代码:-

app.post('/apply',(req,res)=>{
    const output=`<p>You have new Job Application</p>
     <h3>Contact & Position Details</h3>
     <ul>
      <li>${req.body.email}</li>
      <li>${req.body.name}</li>
      <li>${req.body.phone}</li>
      <li>${req.body.position}</li>
     </ul>`;
      console.log(path.dirname(req.body.resume));
      var file =req.body.resume;
     let transporter=nodemailer.createTransport({
         service:'gmail',
         auth:{
             user:'<email>',
             pass:'<password>'
         },
         tls:{
             rejectUnauthorized:false
         }
     });
     let mailOptions={
         from:'"Resume for review" <atul.11192@gmail.com>',
         to:'atul.11192@gmail.com',
         subject:'Job Application',
         text:'Hi ! I have applied at datadock',
         html:output,
         attachments:[{
             filename:file,
             path:path.dirname(file)
         }]

     };
     transporter.sendMail(mailOptions,(error,info)=>{
         if(error)
         {
             return console.log(error);
         }
        res.render('final.ejs',{message:'Email has been sent'}); 
     });
});

谁能告诉我如何解决这个问题?我愿意使用另一个图书馆

0 个答案:

没有答案