Php SendGrid:缺少SendGrid\Email::_构造()的参数1

Php SendGrid:缺少SendGrid\Email::_构造()的参数1,php,sendgrid,Php,Sendgrid,我确信这是一个简单的解决方案,我正在尝试设置一个sendgrid来发送确认电子邮件 require 'sendgrid-php/vendor/autoload.php'; $sendgrid = new SendGrid($user,$pass); $email = new SendGrid\Email(); $email->addTo($sEmail) ->setFrom($email) ->setSubject("Sending with S

我确信这是一个简单的解决方案,我正在尝试设置一个sendgrid来发送确认电子邮件

require 'sendgrid-php/vendor/autoload.php';
$sendgrid = new SendGrid($user,$pass);
$email    = new SendGrid\Email();

$email->addTo($sEmail)
      ->setFrom($email)
      ->setSubject("Sending with SendGrid is Fun")
      ->setHtml("and easy to do anywhere, even with PHP");

$sendgrid->send($email);
执行代码后,我会收到以下错误消息:

 Warning: Missing argument 1 for SendGrid\Email::__construct()
我正在运行PHP版本5.6.16


我确信我错过了一些愚蠢的东西

SendGrid PHP库有一些更新。请参见自述文件中的示例:


SendGrid PHP库有一些更新。请参见自述文件中的示例:


我也在处理发送网格的类似问题

我通过添加下面的标题来实现它


“内容类型”:“application/json;charset=utf8”

我也在处理发送网格的类似问题

我通过添加下面的标题来实现它


“内容类型”:“application/json;charset=utf8”

我们如何在此处添加附件?您好,我只是按照相同的步骤,但显示了此错误:Array{“errors”:[{“message”:“Permission denied,error credentials”,“field”:null,“help”:null}]}我们如何在此处添加附件?您好,我只是按照相同的步骤,但显示了此错误:Array{“错误”:[{“消息”:“权限被拒绝,凭据错误”,“字段”:null,“帮助”:null}]}
<?php
// If you are using Composer
require 'vendor/autoload.php';

// If you are not using Composer (recommended)
// require("path/to/sendgrid-php/sendgrid-php.php");

$from = new SendGrid\Email(null, "test@example.com");
$subject = "Hello World from the SendGrid PHP Library!";
$to = new SendGrid\Email(null, "test@example.com");
$content = new SendGrid\Content("text/plain", "Hello, Email!");
$mail = new SendGrid\Mail($from, $subject, $to, $content);

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);

$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
echo $response->headers();
echo $response->body();