如何在 Postman 中使用 SendGrid 的 Inbound Parse Webhook 示例?

Posted

技术标签:

【中文标题】如何在 Postman 中使用 SendGrid 的 Inbound Parse Webhook 示例?【英文标题】:How do I use SendGrid's Inbound Parse Webhook example in Postman? 【发布时间】:2017-02-10 12:02:35 【问题描述】:

我试图弄清楚为什么收到的电子邮件在我的 Ruby on Rails 应用程序中使用 Griddler 和 SendGrid 删除了段落。为此,我想使用 Postman 模拟入站电子邮件。

SendGrid 有an example 'Default Payload',看起来像这样:

[Date] array(16) 
  ["headers"]=>
  string(1970) "Received: by mx0047p1mdw1.sendgrid.net with SMTP id 6WCVv7KAWn Wed, 27 Jul 2016 20:53:06 +0000 (UTC)
Received: from mail-io0-f169.google.com (mail-io0-f169.google.com [209.85.223.169]) by mx0047p1mdw1.sendgrid.net (Postfix) with ESMTPS id AA9FFA817F2 for <parse@parse.yourdomain.com>; Wed, 27 Jul 2016 20:53:06 +0000 (UTC)
Received: by mail-io0-f169.google.com with SMTP id b62so81593819iod.3 for <parse@parse.yourdomain.com>; Wed, 27 Jul 2016 13:53:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sendgrid.com; s=ga1; h=mime-version:from:date:message-id:subject:to; bh=DpB1CYYeumytcPF3q0Upvx3Sq/oF4ZblEwnuVzFwqGI=; b=GH5YTxjt6r4HoTa+94w6ZGQszFQSgegF+Jlv69YV76OLycJI4Gxdwfh6Wlqfez5yID 5dsWuqaVJZQyMq/Dy/c2gHSqVo60BKG56YrynYeSrMPy8abE/6/muPilYxDoPoEyIr/c UXH5rhOKjmJ7nICKu1o99Tfl0cXyCskE7ERW0=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=DpB1CYYeumytcPF3q0Upvx3Sq/oF4ZblEwnuVzFwqGI=; b=Sq6LVHbmywBdt3sTBn19U8VOmelfoJltz8IcnvcETZsYwk96RBxN+RKMN5fOZSKw4j 15HrgdIFfyDmp67YK0ygvOITlTvZ6XY5I0PtnvDtAQt79kS3tKjI3QKJoEp/ZjIjSzlL KG7agl6cxFgBbIN0yHWBOvy3O+ZXY8tZdom1yOvULjmjW1U9JkdOs+aJ6zq4qhZX/RM/ tIgLB461eJ5V95iQDDc5Ibj9Cvy4vJfXLQRO0nLVQAT2Yz58tkEO1bDZpWOPAyUNneIL yhIWp+SpbuqhMA68mq0krG1PjmWalUbpVcGJIGuOKB9mQFFo/MqdrUCjvYnyo1jPLPeX psdQ==
X-Gm-Message-State: AEkoousvdxmDoxLlTUYJ1AOmCGJv77xRBBlfKv6YrthH0M2NueMwlOxUD6t8nidE9uonXbdJ/DQy/chmHUnN//a4
X-Received: by 10.107.6.101 with SMTP id 98mr38024553iog.41.1469652785829; Wed, 27 Jul 2016 13:53:05 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.107.48.17 with HTTP; Wed, 27 Jul 2016 13:53:05 -0700 (PDT)
From: Sender Name <example@example.com>
Date: Wed, 27 Jul 2016 14:53:05 -0600
Message-ID: <CAN_P_JMvV7ZpAQhOnDienypLrJmuhN=LQWweu4yScw4jQyXY2w@mail.gmail.com>
Subject: Different File Types
To: parse@parse.yourdomain.com
Content-Type: multipart/mixed; boundary=001a113f8ad03e85160538a4343c
"
  ["dkim"]=>
  string(22) "@sendgrid.com : pass"
  ["content-ids"]=>
  string(37) ""ii_1562e2169c132d83":"attachment1""
  ["to"]=>
  string(26) "parse@parse.yourdomain.com"
  ["html"]=>
  string(479) "<div dir="ltr">Here's an email with multiple attachments<div><br></div><div><img src="cid:ii_1562e2169c132d83"   ><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><img src="https://sendgrid.com/brand/sg-logo-email.png"  ><br><div><br></div></div></div>
</div></div>
"
  ["from"]=>
  string(33) "Sender Name <example@example.com>"
  ["text"]=>
  string(139) "Here's an email with multiple attachments
"
  ["sender_ip"]=>
  string(14) "209.85.223.169"
  ["spam_report"]=>
  string(844) "Spam detection software, running on the system "mx0047p1mdw1.sendgrid.net", has
identified this incoming email as possible spam.  The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email.  If you have any questions, see
@@CONTACT_ADDRESS@@ for details.

Content preview:  Here's an email with multiple attachments [image: Inline image
   1] -- [...]

Content analysis details:   (2.6 points, 5.0 required)

 pts rule name              description
---- ---------------------- --------------------------------------------------
 0.8 HTML_IMAGE_RATIO_02    BODY: HTML has a low ratio of text to image area
 0.0 HTML_MESSAGE           BODY: HTML included in message
 1.8 HTML_IMAGE_ONLY_08     BODY: HTML: images with 400-800 bytes of words
 0.0 T_MIME_NO_TEXT         No text body parts

"
  ["envelope"]=>
  string(66) ""to":["parse@parse.yourdomain.com"],"from":"example@example.com""
  ["attachments"]=>
  string(1) "2"
  ["subject"]=>
  string(20) "Different File Types"
  ["spam_score"]=>
  string(5) "2.597"
  ["attachment-info"]=>
  string(287) ""attachment2":"filename":"DockMcWordface.docx","name":"DockMcWordface.docx","type":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","attachment1":"filename":"MG_2359.jpg","name":"_MG_2359.jpg","type":"image/jpeg","content-id":"ii_1562e2169c132d83""
  ["charsets"]=>
  string(77) ""to":"UTF-8","html":"UTF-8","subject":"UTF-8","from":"UTF-8","text":"UTF-8""
  ["SPF"]=>
  string(4) "pass"

我的问题是我真的不明白如何将这种格式放入 Postman,因为 Postman 无法指定这样的原始有效负载。或者,我可以使用 curl 来实现类似的功能吗?

【问题讨论】:

你有没有运气弄明白这个? 【参考方案1】:

我想在本地测试一个 azure 函数应用并设法模拟一个请求

    在https://requestbin.com 创建一个请求箱 在 sendgrid 入站 api 页面上,添加一个 host/url 以重定向到创建的请求 bin 向测试邮箱发送测试邮件 返回请求 bin 页面,复制您在“RAW BODY”下看到的所有内容。 将原始正文粘贴到 Postman 请求正文中 为了让它工作,我还将一些标题复制到 Postman,主要是 "Content-type" = "multipart/form-data;boundary=xYzZY"

【讨论】:

以上是关于如何在 Postman 中使用 SendGrid 的 Inbound Parse Webhook 示例?的主要内容,如果未能解决你的问题,请参考以下文章

如何删除使用 sendgrid 发送的 gmail 中的“查看整个邮件”选项

如何将动态数据传递到sendgrid webapp上设计的电子邮件模板? : - | Sendgrid

如何在我的 Sendgrid 事务模板中包含 Jinja2 模板

如何配置Node email-template使用SendGrid作为传输方式

如何使用SendGrid将图像嵌入到Node.js中的html邮件中

如何使用Sendgrid调用动态html文件中的名称和邮件地址?