2013-06-20 39 views
0

你好我使用节点邮件发送邮件。它工作正常进行attachment.But每当我给一些附件需要默认的内容“数据”作为它的内容。我应该怎样避免这种..附件在节点邮件程序中无法正常工作?

我节点的邮件功能是看起来像这样...

function sendMail(toMailId, subject, body) { 
    for (var i = 0; i < 1; i++) { 
     email.send({ 
      ssl: true, 
      host: DbConfig.mailConfig.host,    
      port: DbConfig.mailConfig.port,    
      domain: DbConfig.mailConfig.domain,   
      to: DbConfig.mailConfig.to, 
      from: DbConfig.mailConfig.from, 
      subject: subject, 
      reply_to: DbConfig.mailConfig.reply_to, 
      body: body, 
      authentication: DbConfig.mailConfig.authentication, 
      username: DbConfig.mailConfig.username,    
      password: DbConfig.mailConfig.password, 
      attachments: [ 
     { 
      filename: "helloworld.txt", 
      content : 'data'  
     } 
     ], 
      debug: DbConfig.mailConfig.debug     
     }, 
    function (err, result) { 
     if (err) { console.log(err); } 
    }); 
    } 
} 

我的问题是,当我收到的邮件在我的收件箱后,打开附件,它只是显示主体数据。除此之外它什么都不显示。当我删除内容意味着它会抛出错误..

的json看起来就像这样:

{ 
"mongodbUrl":"mongodb://USERID:[email protected]:27017/DBNAME", 
"mailConfig" :{ 
      "to":"[email protected]", 
      "host": "smtp.gmail.com",    
      "port": 465,      
      "domain": "[127.0.0.1]",   
      "from":"[email protected]" , 
      "subject":"This is my mail subject, 
       "reply_to": "[email protected]", 
       "authentication": "login",  
       "username": "[email protected]",   
       "password": "pswd", 
       "debug": true  

} 
} 

当我发送PDF文件意味着它是不开放。当发送文本文件,意味着它与开'内容数据'..怎么处理这个?

回答

0

我想你使用的是Marak/node_mailer而不是andris9/Nodemailer。第一个回购本身说它已弃用,并指向第二个回报,你可以在它的github页面看到。

项目有利于nodemailer

的弃用您可以通过

npm install nodemailer 

或从github repo安装Nodemailer。暴露的邮件函数将是sendMail而不是send

您可以在此folder中看到更多使用电子邮件附加文件的示例。