【问题标题】:SendGrid Web API bounced email header responseSendGrid Web API 退回的电子邮件标头响应
【发布时间】:2014-08-29 11:22:06
【问题描述】:

我正在通过SendGrid 发送电子邮件,其中x-smtpapi header 内包含此内容

$json_string = array(
    'unique_args' => array (
        'email_id' => 1
    )
);

似乎一切正常,在 SendGrid 中,我可以在 Unique Args 下的电子邮件活动中查看“email_id”。

但是,当我尝试使用 API 查看这封电子邮件时,我找不到真正从 API 获取这些独特参数的方法。

我正在使用它来尝试获取与退回的电子邮件一起返回的标题。

$request = 'https://api.sendgrid.com/api/bounces.get.json&api_user=username&api_key=password'

我得到的只是退回的电子邮件地址,而不是标题信息(唯一参数)

我想知道,是否可以从API 中获取唯一参数。看了好几遍都没用。

我希望这是有道理的。 谢谢

【问题讨论】:

标签: php api sendgrid


【解决方案1】:

目前无法通过 Web API 请求通过 unique_arg 查找特定事件。

但是,SendGrid Event Webhook 将为您提供每个事件的详细数据,例如反弹。每次对电子邮件执行操作时,事件 Webhook 都会将数据发布到您的服务器(例如 openclickbounce)。

一旦您收到它,您就有责任存储它,虽然它不是一个典型的 API,但它会提供非常具体的事件数据,然后您可以根据需要编译和重新散列。

要开始使用 webhook,您需要执行以下操作,并让 SendGrid POST 到以下脚本:

<?php
$data = file_get_contents("php://input");
$events = json_decode($data, true);

foreach ($events as $event) {
  // Here, you now have each event and can process them how you like
  process_event($event);
}

[取自SendGrid Webhook Code Example]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-14
    • 2016-11-30
    • 2020-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-23
    相关资源
    最近更新 更多