如何发送电子邮件到NodeJS中的Mandrill列表?
问题描述:
我似乎无法在任何地方找到明确的答案。我有一个数据库充满了我需要获取的电子邮件地址,然后在NodeJS中附加到Mandrill电子邮件。我有一个基本的消息构建,并可以发送给一个收件人。我需要将1000个收件人列表附加到邮件中。这是我的。它来自Mandrill文档中的示例,然后进行了修改。我在哪里以及如何列入我的列表?我看到to:属性是一个数组,我只是在那里添加一个对象数组的变量,然后将它发送给Mandrill?谢谢你的帮助!如何发送电子邮件到NodeJS中的Mandrill列表?
var message = {
"html": html,
"subject": "Subject",
"from_email": "[email protected]",
"from_name": "recipient",
"to": [{
"email": "[email protected]",
"name": "Recipient Name",
"type": "to"
},
{
"email": "[email protected]",
"name": "Pickle McGillicuddy",
"type": "to"
}],
"headers": {
"Reply-To": "[email protected]"
},
"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": "[email protected]",
"tracking_domain": null,
"signing_domain": null,
"return_path_domain": null,
"merge": true,
"global_merge_vars": [{
"name": "merge1",
"content": "merge1 content"
}],
"merge_vars": [{
"rcpt": "[email protected]",
"vars": [{
"name": "merge2",
"content": "merge2 content"
}]
}],
"tags": [
"password-resets"
]
};
答
就在message
每个电子邮件地址添加到to
阵列。我想你正在寻找一些沿着这些方向的东西:
var message = { ... };
var emailAddresses = ... // get from database
for (var i in emailAddresses) {
message.to.push({
email: emailAddresses[i],
type: 'to'
});
}
优秀!我找不到任何文件。猜猜我忽略了一些东西。谢谢! – adamgedney 2014-09-26 20:29:46