【问题标题】:Defining X-SMTPAPI header定义 X-SMTPAPI 标头
【发布时间】:2013-11-07 18:55:40
【问题描述】:

问题1:定义X-SMTPAPI时是否需要严格按照顺序 文档中提到的标头相关顺序?

文档(http://sendgrid.com/docs/API_Reference/SMTP_API/) 是这样提到的:

{
  "to": [
    "ben@sendgrid.com",
    "joe@sendgrid.com"
  ],
  "sub": {
    "%name%": [
      "Ben",
      "Joe"
    ],
    "%role%": [
      "%sellerSection%",
      "%buyerSection%"
    ]
  },
  "section": {
    "%sellerSection%": "Seller information for: %name%",
    "%buyerSection%": "Buyer information for: %name%"
  },
  "category": "Orders",
  "unique_args": {
    "orderNumber": "12345",
    "eventID": "6789"
  },
  "filters": {
    "footer": {
      "settings": {
        "enable": 1,
        "text/plain": "Thank you for your business"
      }
    }
  }
}


So, my email header in this case would look like the following in  coldfusion:



 <cfset myheaderdefinition = XMLFormat('X-SMTPAPI|{
      "to": [
        "ben@sendgrid.com",
        "joe@sendgrid.com"
      ],
      "sub": {
        "%name%": [
          "Ben",
          "Joe"
        ],
        "%role%": [
          "%sellerSection%",
          "%buyerSection%"
        ]
      },
      "section": {
        "%sellerSection%": "Seller information for: %name%",
        "%buyerSection%": "Buyer information for: %name%"
      },
      "category": "Orders",
      "unique_args": {
        "orderNumber": "12345",
        "eventID": "6789"
      },
      "filters": {
        "footer": {
          "settings": {
            "enable": 1,
            "text/plain": "Thank you for your business"
          }
        }
      }
    }
    ') > 

问题 #2:我定义标题的方式看起来不错吗?

关于问题 #1 的更多说明:

1.1 我是否需要按照上述相同的顺序使用 to、sub、role、section 等?或者,如果我不使用这些,我可以跳过其中一个吗?

1.2 我如何确定 sendgrid 对 unique_args 和其他字段的期望?

【问题讨论】:

  • 为什么你觉得你需要使用 SMTPAPI?您打算使用 API 的什么功能?

标签: sendgrid


【解决方案1】:

1 - 1.1 您可以在您提供的 SendGrid 的 JSON 对象中按您希望的任何顺序使用任意数量的 SMTPAPI 参数。你可以省略那些你不使用的。 SendGrid 文档中提供的示例仅此而已,不是必需的。

1.2 unique_args 和其余参数是仅供您使用的字段。 SendGrid 不期待任何东西。当您提供参数时,SendGrid 将按照SMTPAPI Documentation 中的说明对其执行。

2 您的设置看起来不正确,虽然我对 ColdFusion 不是很熟悉,但您似乎没有正确定义电子邮件标题。我会向my previous answer to your previous question 指出如何设置它。


但是,基于这个问题和之前的问题,我必须问,您确定要使用 SendGrid 的 SMTPAPI 还是只使用 SMTP 向 SendGrid 发送电子邮件?

基于通过 JSON 对象提供给它的参数,SMTPAPI 为电子邮件提供了许多附加功能。但是,通过 SMTP 发送只是使用 SMTP 协议将您的消息传输到 SendGrid。


编辑:要进一步检查您的 SMTPAPI 标头,您可能需要使用 SMTPAPI Header Validator

【讨论】:

    猜你喜欢
    • 2016-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-14
    • 1970-01-01
    • 2016-09-07
    相关资源
    最近更新 更多