简体   繁体   中英

meteor.js email.send not working when trying to send to array of users

so my email.send is working but only if im sending email only to one user. here is the code inside of a 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
    });
}

});

working client code:

Meteor.call('sendEmail',
            'yechielxxx@gmail.com',
            'boazxxx@gmail.com',
            'test',
            'testing meteor email');

not working:

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

what am i missing here? this is what docs.meteor says "to String or Array of strings RFC5322 "To:" address[es]"

im using an array of users everything should be working fine.

I tested this on v0.6.5.1 and Email.send will take an array, but your code isn't running because the check will fail when you pass an array for to . As written, it's looking for all inputs to be strings. If you modify it to something like:

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

Then you can pass a string or an array to sendEmail and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM