定义X-SMTPAPI标头

时间:2013-11-07 18:55:40

标签: sendgrid

问题1:在定义X-SMTPAPI时是否需要严格遵循命令 文档中提到的标题相关顺序?

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

1 个答案:

答案 0 :(得分:0)

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发送电子邮件?

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


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