SendGrid not working

834 views
Skip to first unread message

Mike Clark

unread,
Jan 8, 2014, 7:13:50 PM1/8/14
to appfog...@googlegroups.com
I'm trying to integrate SendGrid into my app and it isn't working. It looked so easy in the example.

I downloaded sendgrid-php (https://github.com/sendgrid/sendgrid-php) and put it in lib/

My php code is as follows:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'lib/SendGrid.php';

$sendgrid = new SendGrid(getenv('SENDGRID_USERNAME'),
                             getenv('SENDGRID_PASSWORD'));

$email = new SendGrid\Email();
$email->
    addTo('em...@email.com')->
    setFrom('em...@email.com')->
    setSubject('Hello')->
    setText('Hello World');

$sendgrid->web->send($email);
?>

But when I load the php file, I get the following error:
Fatal error: Class 'SendGrid\Email' not found in /mnt/var/vcap.local/dea/apps/<directory removed>/app/email_test.php on line 9

Why?

Mike Clark

unread,
Jan 8, 2014, 8:11:13 PM1/8/14
to appfog...@googlegroups.com
Update:

I setup composer on my machine and am now using the autoload feature. That has helped tremendously, but sendgrid still does not work. The error I get now is
Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set...

Any thoughts?

Mike Clark

unread,
Jan 25, 2014, 10:49:57 AM1/25/14
to appfog...@googlegroups.com
For any who come across this problem in the future, I got it working.

I ended up using composer to download sendgrid and all the dependencies. Then switching to SMTP instead of web mail for sendgrid. This then worked.

I'm thinking the documentation on appfog needs to be updated.
Reply all
Reply to author
Forward
0 new messages