SendGrid v3 400错误请求

时间:2016-09-05 16:10:19

标签: php sendgrid

我正在使用 sendgrid / sendgrid-php the repo on github发送跨国电子邮件。今天我更新了库,新版本使用了API v3,而之前我使用过v2。我根据他们的示例更改了代码,这里是我的SendGrid \ Mail对象的转储:

enter image description here

问题是我不断收到400 BAD REQUEST错误而没有任何其他信息:

enter image description here

我做错了什么?邮件对象似乎是正确的。

我正在尝试按以下方式发送电子邮件:

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
$request_body = [creating the mail object];
$response = $sg->client->mail()->send()->post($request_body);

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,并发现所有个性化都需要是带双引号的字符串。在您的示例中:

$md_email_id = (string)26921

更多信息https://github.com/sendgrid/sendgrid-php/issues/264

相关问题