A very simple component to use the Sendgrid API inside CakePHP
Switch branches/tags
Nothing to show
Clone or download
damusnet Merge pull request #1 from mikerogerz/patch-1
Sendgrid API accepts an array of addresses
Latest commit f461a30 Jun 28, 2011


Sendgrid CakePHP component

Copyright 2011, Damien Varron Licensed under The MIT License Redistributions of files must retain the above copyright notice.


Written for CakePHP 1.3+


Add the following lines to your core configuration file with your own credentials:

Configure::write('Sendgrid.username', 'your@email.com');
Configure::write('Sendgrid.password', 'yourpassword');


This component extends the base CakePHP email component, and works virtually the same.

Place the sendgrid.php file in your app/controllers/components/ folder.

In your controller, make sure the component is available:

public $components = array('Sendgrid');   

Then, simply send messages like this:

$this->Sendgrid->delivery = 'sendgrid';
$this->Sendgrid->from = 'sender@domain.com';
$this->Sendgrid->to = 'recipient@domain.com';
$this->Sendgrid->subject = 'this is the subject';
$messageBody = 'this is the message body';

The syntax of all parameters is the same as the default CakePHP email component:


For more information, see the Sendgrid API documentation:



You can see the response from Sendgrid in the return value when you send a message:

$result = $this->Sendgrid->send($messageBody);
$this->log($result, 'debug');