我似乎无法在任何地方找到明确的答案。我有一个数据库,其中包含我需要获取的电子邮件地址,然后附加到NodeJS中的Mandrill电子邮件中。我有一个基本的消息构建,可以发送给一个收件人。我需要将我的1000个收件人列表附加到邮件中。这就是我所拥有的。它取自Mandrill文档中的一个示例,然后进行了修改。我在哪里以及如何列入我的清单?我看到to:属性是一个数组,我只是在那里添加一个对象数组的变量,然后将其发送给Mandrill?谢谢你的帮助!
var message = {
"html": html,
"subject": "Subject",
"from_email": "recipient@gmail.com",
"from_name": "recipient",
"to": [{
"email": "recipient@gmail.com",
"name": "Recipient Name",
"type": "to"
},
{
"email": "recipient@gmail.com",
"name": "Pickle McGillicuddy",
"type": "to"
}],
"headers": {
"Reply-To": "recipient@gmail.com"
},
"important": false,
"track_opens": null,
"track_clicks": null,
"auto_text": null,
"auto_html": null,
"inline_css": null,
"url_strip_qs": null,
"preserve_recipients": null,
"view_content_link": null,
"bcc_address": "recipient@gmail.com",
"tracking_domain": null,
"signing_domain": null,
"return_path_domain": null,
"merge": true,
"global_merge_vars": [{
"name": "merge1",
"content": "merge1 content"
}],
"merge_vars": [{
"rcpt": "recipient@gmail.com",
"vars": [{
"name": "merge2",
"content": "merge2 content"
}]
}],
"tags": [
"password-resets"
]
};
答案 0 :(得分:0)
只需将每个电子邮件地址添加到to
中的message
数组即可。我认为你正在寻找这些方面的东西:
var message = { ... };
var emailAddresses = ... // get from database
for (var i in emailAddresses) {
message.to.push({
email: emailAddresses[i],
type: 'to'
});
}