我有在发送邮件给多个收件人的问题。
我的脚本
var SendGrid = require('sendgrid').SendGrid;
var sendgrid = new SendGrid('<<username>>', '<<password>>');
sendgrid.send({
to: 'nabababa@gmail.com',
from: 'sengupta.nabarun@gmail.com',
bcc: ["sengupta.nabarun@gmail.com","sengupta_nabarun@rediffmail.com"],
我有两个问题在这里
- 我能有收件人的数组中列出?
- 如何有收件人在密件抄送列表数组?
与上述两个查询的解决方案将是有益的确实
由于Nabarun
您可以同时在使用收件人的阵列to
和bcc
领域。
例如:
var SendGrid = require('sendgrid').SendGrid;
var sendgrid = new SendGrid('{{sendgrid username}}', '{{sendgrid password}}');
sendgrid.send({
to: ['one@example.com', 'two@example.com'],
from: 'nick@sendgrid.com',
bcc: ['three@example.com', 'four@example.com'],
subject: 'This is a demonstration of SendGrid sending email to mulitple recipients.',
html: '<img src="http://3.bp.blogspot.com/-P6jNF5dU_UI/TTgpp3K4vSI/AAAAAAAAD2I/V4JC33e6sPM/s1600/happy2.jpg" style="width: 100%" />'
});
如果这不是为你工作和节点没有吐出任何错误,请检查该邮件被发送,通过登录SendGrid的网站和看电子邮件活动日志 。
我碰到在测试您的代码示例的一件事是,如果你发送to
和bcc
到相同的Gmail地址,Gmail将它全部合并成一个电子邮件(所以没有工作出现)。 测试你发送电子邮件到完全不同的帐户时,请确保。
如果你需要一些电子邮件帐户来测试游击队邮件是一个用于创建临时测试帐户一个很好的选择。
对于Sendgrid的V3 API,我发现自己的“厨房水槽”的例子有帮助的。 下面是它相关位:
var helper = require('sendgrid').mail
mail = new helper.Mail()
email = new helper.Email("test@example.com", "Example User")
mail.setFrom(email)
mail.setSubject("Hello World from the SendGrid Node.js Library")
personalization = new helper.Personalization()
email = new helper.Email("test1@example.com", "Example User")
personalization.addTo(email)
email = new helper.Email("test2@example.com", "Example User")
personalization.addTo(email)
// ...
mail.addPersonalization(personalization)
新sendgrid-更新的NodeJS已报废之前的实现方法,因此接受的答案不会帮助你了。
所以...以防万一任何人更新土地此主题与特定的搜索结果。
to: [
{
email: 'email1@email.com',
},
{
email: 'email2@email.com',
},
],