send-grid-mailer

php yii send grid mailer wrapper
5 followers

INSTALLATION

'imports' => array(
    'ext.sendgrid.YiiSendGridMail'
),
'components' => array(
    .....
    'sendGrid' => array(
        'class' => 'ext.sendgrid.YiiSendGrid',
        'username' => 'my_username',
        'password' => 'my_password',
        'api' => 'web' // can be smtp or web
        // custom behavior
        'logging' => true, // default to true
        'dryRun' => false,
    ),
),

Usage

send email using text

/* @var $sendGrid YiiSendGridMail */
$sendGrid = Yii::app()->sendGrid;
 
$mail = new YiiSendGridMail();
$mail->addTo('bryglen16@yahoo.com','Bryan Tan')
    ->setFrom('bryantan16@gmail.com')
    ->setSubject('Test Send Grid')
    ->setText('Hello World');
 
$response = $sendGrid->send($mail);

send email using HTML

/* @var $sendGrid YiiSendGridMail */
$sendGrid = Yii::app()->sendGrid;
 
$mail = new YiiSendGridMail();
$mail->addTo('admin@webmaster.com','Bryan Tan')
    ->setFrom('bryantan16@gmail.com')
    ->setSubject('Test Send Grid')
    ->setHtml('<strong>Hello World</strong>');
 
$response = $sendGrid->send($mail);

send email using Yii view

/* @var $sendGrid YiiSendGridMail */
$mail = new YiiSendGridMail();
$mail->setView('/mail/account-block',array('model' => new User()));
$mail->addTo('bryglen16@yahoo.com','Bryan Tan')
    ->setFrom('bryantan16@gmail.com')
    ->setSubject('Test Send Grid');
 
$response = $sendGrid->send($mail);

Resources

Download the extension on Github

Total 3 comments

#16087 report it
Danny V at 2014/01/18 11:10am
Error

That's not it... Already got it working... Changed the spl loader.

#16086 report it
bryglen at 2014/01/18 10:44am
error

'api' => 'smtp' // can be smtp or web

use "web" instead of smtp.. that will solve your problem.

#15941 report it
Danny V at 2013/12/31 01:32pm
Error, Probably dependent resources?

I've installed the extension but i'm getting:

include(Swift.php): failed to open stream: No such file or directory

Do i need to install any dependent package?

Thx.

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet