我刚刚配置了我的 SendGrid 帐户并将 zip 文件上传到我的服务器,现在我正在尝试将它与我的 Zend Framework 项目集成。我试图慢慢整合,所以我一次只会遇到一些错误,从创建电子邮件开始,然后再尝试发送。到目前为止,这就是我所拥有的:
require_once(BASE_PATH . "/library/sendgrid-php/SendGrid.php");
require_once(BASE_PATH . "/library/sendgrid-php/SendGrid_loader.php");
$sendgrid = new SendGrid($username, $password);
$mail = new SendGrid/Mail();
$mail->addTo($email)
->setSubject('Subject')
->setText('');
//$sendgrid->smtp->send($mail);
顺便说一句,第一个 require 在那里,因为 SendGrid 加载器因为找不到 SendGrid.php 而抛出错误。无论如何,只有这几行代码会产生所有这些错误:
Warning: Missing argument 1 for SendGrid::__construct(), called in
...InviteController.php on line 51 and defined in
...library/sendgrid-php/SendGrid.php on line 13
Warning: Missing argument 2 for SendGrid::__construct(), called in
...InviteController.php on line 51 and defined in
...library/sendgrid-php/SendGrid.php on line 13
Warning: mail() expects at least 3 parameters, 0 given in
...InviteController.php on line 51
Warning: Division by zero in ...InviteController.php on line 51
Fatal error: Call to a member function addTo() on a non-object in
...InviteController.php on line 52
SendGrid 自己的指南http://docs.sendgrid.com/documentation/get-started/integrate/examples/php-email-example-using-smtp/基本上只是说将文件上传到您的服务器并包含加载器和您'准备好了。我绝对不明白为什么我会得到所有这些错误。我错过了设置它的步骤还是什么?