【问题标题】:meteor.js email.send not working when trying to send to array of users尝试发送给用户数组时,meteor.js email.send 不起作用
【发布时间】:2013-10-17 09:10:01
【问题描述】:

所以我的 email.send 可以正常工作,但前提是我只向一个用户发送电子邮件。 这是meteor.method里面的代码:

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',
            'yechielxxx@gmail.com',
            'boazxxx@gmail.com',
            'test',
            'testing meteor email');

不工作:

 Meteor.call('sendEmail',
                ['yechielxxx@gmail.com','boazxxx@gmail.com','boazxxx@walla.co.il'],
                'boazxxx@gmail.com',
                'test',
                'testing meteor email');

我在这里错过了什么?这就是 docs.meteor 所说的“对字符串或字符串数​​组 RFC5322“收件人:”地址[es]”

我使用了一组用户,一切都应该可以正常工作。

【问题讨论】:

    标签: javascript arrays email meteor


    【解决方案1】:

    我在v0.6.5.1 上对此进行了测试,Email.send 将采用一个数组,但您的代码没有运行,因为当您为to 传递一个数组时检查将失败。如所写,它正在寻找所有输入都是字符串。如果您将其修改为:

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

    然后您可以将字符串或数组传递给sendEmail,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 2013-06-21
      • 2021-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-23
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      相关资源
      最近更新 更多