在使用 PHP 通过发送网格发送邮件时获取响应


Get Response while sending mail through sendgrid using PHP

我正在通过sendgrid发送邮件。我正在使用sendgrid-php库。发送邮件后,我收到了邮件。

$sendgrid = new SendGrid($username, $password,array("turn_off_ssl_verification" =>   true));
$email = new SendGrid'Email();
 $emailaddress=array('xxx@gmail.com','yyy@gmail.com','hjhjh@radiare.com');
  $email->setTos($emailaddress)->
   setFrom('hjhkjhk@gmail.com')->
   setSubject('Test Mail')->
   setText('Hi i have sent you a mail!')->
   setHtml('<strong>Hello World!</strong>');
 $response=$sendgrid->send($email);
 print_r($response);

打印响应后,我得到此输出

stdClass Object ( [message] => success ) 

即使邮件地址不正确。我得到了相同的输出。

成功意味着 SendGrid 已成功收到您的消息,并已开始处理它。若要了解消息的最终状态,需要实现事件 Webhook,这需要铜牌或更高版本的包。