This is invalid javascript "to": [{"email": "email1", "email2"}]
Change it to
"to": [{"email": "email1"},{"email": "email2"}]
In javascript the []
is an array and {}
is an object with key/value pairs. So "to" should be an array of objects like {"email": "some@email.com"}
Edit
To map your array of emails to an array of such objects you can for instance use jQuery.map
// Try doing something like this
var emailObjects = $.map(emails, function(email) {
return {"email": email};
});
And then change your params
to the following
var params = {
"message": {
"from_email": "rich@pachme.com",
"to": emailObjects,
"subject": "Sending a text email from the Mandrill API",
"text": "I'm learning the Mandrill API at Codecademy."
}
};