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', '[email protected]');
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 = '[email protected]';
$this->Sendgrid->to = '[email protected]';
$this->Sendgrid->subject = 'this is the subject';
$messageBody = 'this is the message body';
$this->Sendgrid->send($messageBody);
The syntax of all parameters is the same as the default CakePHP email component:
http://book.cakephp.org/view/1283/Email
For more information, see the Sendgrid API documentation:
http://sendgrid.com/documentation/display/api/WebMail
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');