Reputation: 882
I just got my SendGrid account provisioned and the zip file uploaded to my server and now I'm trying to integrate it with my Zend Framework project. I tried to integrate slowly so I would only get a few errors at a time, starting off with just creating an email before trying to send it. This is all I have so far:
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);
By the way, the first require is in there because SendGrid loader threw an error because it couldn't find SendGrid.php. Anyway, just these few lines of code produce all of these errors:
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's own guide, http://docs.sendgrid.com/documentation/get-started/integrate/examples/php-email-example-using-smtp/, basically just says upload the files to your server and include the loader and you're ready to go. I absolutely do not understand why I would be getting all of these errors. Did I miss a step in setting it up or something?
Upvotes: 1
Views: 2128
Reputation: 882
It was just an outdated version of PHP. Sendgrid requires at least 5.3 for its namespace feature (the slash in the class name), to work correctly. My code couldn't evaluate the namespace and so it couldn't find the class it needed.
Upvotes: 2