0

问题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 和其他字段的期望?

4

1 回答 1

0

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

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

2 您的设置看起来不正确,虽然我对 ColdFusion 不是很熟悉,但您似乎没有正确定义电子邮件标题。我会指出我之前对您之前关于如何设置的问题的回答。


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

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


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

于 2013-11-07T20:19:46.637 回答