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
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.
error
'api' => 'smtp' // can be smtp or web
use "web" instead of smtp.. that will solve your problem.
Error
That's not it... Already got it working... Changed the spl loader.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.