【问题标题】:Sendgrid Web API -- set multiple users in reply_to fieldSendgrid Web API -- 在 reply_to 字段中设置多个用户
【发布时间】:2013-04-04 19:50:22
【问题描述】:

我正在使用 Sendgrid Python 库,我想在“reply_to”字段中与多人一起发送电子邮件。

我想向 2 个人发送一封电子邮件,以便两个用户可以通过点击回复相互发送电子邮件。最简单的解决方案似乎是将两个用户都放在回复字段中。

我在 Sendgrid 文档中没有看到任何方法可以做到这一点——他们似乎只想要在他们的“reply_to”字段中使用一个电子邮件地址字符串。但是,我知道具有此特征的电子邮件是可能的(请原谅预算编辑工作):

无论如何,如您所见,“回复”中的多个条目是可能的。那么有人知道如何使用 Sendgrid 来实现吗?

【问题讨论】:

    标签: email sendgrid reply


    【解决方案1】:

    是的,SendGrid 可以做到这一点。要添加多个“回复”条目,您必须使用自定义标题。

    所以在 Python 中,你会添加:

    message.add_header("Reply-To", "user1@email.com, user2@email.com")
    

    【讨论】:

    • 如何在web api中添加?
    • message.headers["Reply-To"] = "user1@email.com, user2@email.com"
    • V3 API 不允许直接设置Reply-To 标头。请参阅sendgrid.com/docs/API_Reference/Web_API_v3/Mail/… 错误消息“标题不能是保留键之一。”。
    【解决方案2】:

    截至今天,无法设置多个回复地址。这是 sendgrid 的 Github 问题:https://github.com/sendgrid/sendgrid-csharp/issues/339

    【讨论】:

      【解决方案3】:

      根据这个打开的issue,这已被讨论为最想要的功能。 现在 SendGrid 支持在 replyTo 中提及多封电子邮件,但他们为此引入了一个新的标头,如 doc 中所述。尽管他们的许多 SDK 都没有这种支持。 更新:现在Sendgrid Mail nodejs library 提供此功能。

      所以我分叉了他们的代码并进行了更改。更改可在 link 上找到,很快我将提出 PR 以将其与他们的代码库合并。

      在replyTo中发送包含多封电子邮件的电子邮件,使用下面给出的代码sn-p:

      const sgMail = require('@sendgrid/mail');
      sgMail.setApiKey(process.env.SENDGRID_API_KEY);
      const msg = {
        to: 'recipient@example.org',
        from: 'sender@example.org',
        subject: 'Multiple mail in replyTo',
        html: '<p>Here’s an example of multiple replyTo email for you!</p>',
        replyToList: [
              {
                  'name': 'Test User1',
                  'email': 'test_user1@example.org'
              },
              {
                  'email': 'test_user2@example.org'
              }
          ],
      };

      【讨论】:

        猜你喜欢
        • 2016-08-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-10
        相关资源
        最近更新 更多