2013-10-09 15 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,它应该工作。