我正在节点中构建一个应用程序,每次有新用户访问预定义的电子邮件数组时,我都使用mandrill发送电子邮件。我有一系列电子邮件:
我有这个功能
newUserEmail(user_name, email) {
emailArray = [example1@ex.com, example2@ex.com, example3@ex.com]
const message = {
html: '<p>Name: *|NAME|* <br> Email: *|EMAIL|*</p>',
text: 'Name: *|NAME|*, Email: *|EMAIL|*',
subject: 'New person arrived',
from_email: 'newperson@example.com',
from_name: 'New',
to: [{
email: emailArray,
type: 'to'
}],
merge: true,
merge_vars: [{
rcpt: emailArray,
vars: [{
name: 'NAME',
content: user_name
}, {
email: 'EMAIL',
content: email
}]
}]
};
mandrill_client.messages.send({ message }, function(result) {
console.log(result);
}, function(e) {
console.log(`A mandrill error occurred: ${e.name} - ${e.message}`);
});
}
我在控制台上看到这个:
[ { email: 'Array',
status: 'invalid',
_id: '...',
reject_reason: null } ]
如果我只设置一封电子邮件,它就会毫无问题地发送。
我是否需要做一个循环,并在数组中多次运行此函数?我希望Mandrill能识别出阵列中的电子邮件:(