send-grid-mailer php yii send grid mailer wrapper

  1. INSTALLATION
  2. Usage
  3. Resources

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

1 0
4 followers
271 downloads
Yii Version: Unknown
License: BSD-2-Clause
Category: Mail
Developed by: bryglen
Created on: Aug 21, 2013
Last updated: 4 years ago

Related Extensions