2013-10-09 14 views
2

所以我的email.send正在工作,但只有當我只發送電子郵件給一個用戶。 這裏是一個meteor.method內部的代碼:meteor.js email.send試圖發送給用戶陣列時不工作

sendEmail: function (to, from, subject, text) { 
    check([to, from, subject, text], [String]); 

    this.unblock(); 

    Email.send({ 
     to: to, 
     from: from, 
     subject: subject, 
     text: text 
    }); 
} 

});

工作的客戶端代碼:

Meteor.call('sendEmail', 
      '[email protected]', 
      '[email protected]', 
      'test', 
      'testing meteor email'); 

不工作:

Meteor.call('sendEmail', 
       ['[email protected]','[email protected]','[email protected]'], 
       '[email protected]', 
       'test', 
       'testing meteor email'); 

缺少什麼我在這裏?這是什麼docs.meteor說:「字符串或字符串陣列 RFC5322」若要:「地址[西]」

即時使用用戶數組一切都應該工作正常。

回答

4

我在v0.6.5.1Email.send上測試了這個數組,但是你的代碼沒有運行,因爲當你傳遞一個數組給to時檢查將失敗。正如所寫,它正在尋找所有的輸入是字符串。如果你把它修改成類似:

check(to, Match.OneOf(String, [String])); 
check([from, subject, text], [String]); 

那麼你可以傳遞一個字符串或數組sendEmail,它應該工作。