Sendgrid-nodejs: 将电子邮件发送给多个收件人,这样每个人都只能在TO标头中看到他们的电子邮件

创建于 2017-01-06  ·  4评论  ·  资料来源: sendgrid/sendgrid-nodejs

您好,

如何使用Web API v3通过一个API调用分别发送邮件,以便每个收件人在“收件人”框中只能看到其地址? 目前,我正在使用nodejs,Web API v3和sendgrid依赖关系发送邮件,但问题是用户在“收件人”框中获得了收件人的整个列表。 这是请求:

var request = sg.emptyRequest({
        method: 'POST',
        path: '/v3/mail/send',
        body: {
            personalizations: [
                {
                    to: recepientEmails,
                    substitutions: emailTemplate.substitutions
                }
            ],
            from: {
                email: '[email protected]',
                name: 'Dorotea from AWW'
            },
            template_id: emailTemplate.template_id,
            categories: emailTemplate.categories
        }
    });

我已经读过Web API v2,我将需要使用x-smtp标头,以便将电子邮件分别发送到表中第一行的每个收件人。
https://sendgrid.com/docs/API_Reference/Web_API/mail.html

而且我已经读到,使用SMTP的Web API v2中的所有内容都可以在此处仅使用一个请求就可以通过Web API v3完成。
https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html

最后,我想使用Web API v3进行一次API调用,以将电子邮件发送到多个地址,并希望每封电子邮件在TO标头中仅包含该收件人电子邮件。

一切顺利
兹沃尼米尔

help wanted question

最有用的评论

@ zvone187

我不知道你是否已经找到了如何做到这一点,但是看起来像你想要什么来实现的。

您应该为每个收件人添加不同的个性化设置。 它应在代码中转换为如下形式:

// This assumes every recipient gets the same substitutions. If not, just add the right substitution for each email
const personalizations = recipientEmails.map(email => ({
    to: [{ email }],
    substitutions: emailTemplate.substitutions
}));
const request = sg.emptyRequest({
    method: 'POST',
    path: '/v3/mail/send',
    body: {
        personalizations,
        from: {
            email: '[email protected]',
            name: 'Dorotea from AWW'
        },
        template_id: emailTemplate.template_id,
        categories: emailTemplate.categories
    }
});

我不确定在一个请求中当前可以发送给的收件人数量的限制是多少。

所有4条评论

@ zvone187

我不知道你是否已经找到了如何做到这一点,但是看起来像你想要什么来实现的。

您应该为每个收件人添加不同的个性化设置。 它应在代码中转换为如下形式:

// This assumes every recipient gets the same substitutions. If not, just add the right substitution for each email
const personalizations = recipientEmails.map(email => ({
    to: [{ email }],
    substitutions: emailTemplate.substitutions
}));
const request = sg.emptyRequest({
    method: 'POST',
    path: '/v3/mail/send',
    body: {
        personalizations,
        from: {
            email: '[email protected]',
            name: 'Dorotea from AWW'
        },
        template_id: emailTemplate.template_id,
        categories: emailTemplate.categories
    }
});

我不确定在一个请求中当前可以发送给的收件人数量的限制是多少。

@iamtheib感谢您的回复。 我从Sengrid得到了答案。 是的,这正是需要做的事情。

它可以工作,但是如何为不同的收件人发送不同的附件呢?
我需要为每个用户发送具有相同模板,不同个性化和不同附件文件的多封电子邮件。

@iamtheib

感谢您的帮助! 请填写此表格,我们会寄给您赃物:)

最诚挚的问候,

埃尔默

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

polkhovsky picture polkhovsky  ·  3评论

thinkingserious picture thinkingserious  ·  4评论

mikemaccana picture mikemaccana  ·  4评论

murphman300 picture murphman300  ·  4评论

umarhussain15 picture umarhussain15  ·  3评论