Permalink
Browse files

allow a single attachment instead of an array

  • Loading branch information...
1 parent b3f7bb2 commit 89b91674a9facfd4b018ed488a3b657cea8f2768 @andris9 andris9 committed Feb 4, 2013
Showing with 8 additions and 3 deletions.
  1. +1 −1 examples/example_smtp.js
  2. +7 −2 lib/nodemailer.js
@@ -18,7 +18,7 @@ var message = {
from: 'Sender Name <sender@example.com>',
// Comma separated list of recipients
- to: '"Receiver Name" <receiver@example.com>',
+ to: '"Receiver Name" <nodemailer@disposebox.com>',
// Subject of the message
subject: 'Nodemailer is unicode friendly ✔', //
View
@@ -315,10 +315,15 @@ Nodemailer.prototype.setAlternatives = function(){
* to the mailcomposer object</p>
*/
Nodemailer.prototype.setAttachments = function(){
- if(!Array.isArray(this.options.attachments)){
+ var attachment;
+
+ if(!this.options.attachments){
return;
}
- var attachment;
+
+ // convert non array value to an array if needed
+ this.options.attachments = [].concat(this.options.attachments);
+
for(var i=0, len=this.options.attachments.length; i<len; i++){
attachment = this.options.attachments[i];
attachment.userAgent = attachment.userAgent || this.generateUserAgentString();

0 comments on commit 89b9167

Please sign in to comment.