通过 SendGrid v3 发送 HTML 内容

Ale*_*zur 9 email go sendgrid sendgrid-api-v3

我使用 GO,尝试通过 sendgrid API v3 发送邮件(https://github.com/sendgrid/sendgrid-go,无需邮件助手类)。但是当我使用这段代码时:

"content": [
    {
      "type": "text/html", 
      "value": "<html><head></head><body>Hello You link <a href="http://example.com/reschedule?id=12334">Click</a></body></html>"
    }
  ], 
Run Code Online (Sandbox Code Playgroud)

我收到错误:

第400章

但这段代码可以正常工作:

"content": [
    {
      "type": "text/html", 
      "value": "<html><head></head><body>Hello!</body></html>"
    }
  ], 
Run Code Online (Sandbox Code Playgroud)

我认为特殊字符有问题,但我该如何解决它?谢谢你!

Ale*_*zur 5

需要这样做:

<div class=\"ad_box\"><img class=\"banner\" src=\"some_ad.png\" alt=\"\" \/>

Example
    "content": [
        {
          "type": "text/html", 
          "value": "<html><head></head><body>Hello You link <a href=\"http://example.com/reschedule?id=12334\">Click</a></body></html>"
        }
      ], 
Run Code Online (Sandbox Code Playgroud)