Created
January 7, 2014 20:12
-
-
Save zeckdude/8306071 to your computer and use it in GitHub Desktop.
Extending Yii CEmailLogRoute class using Mailgun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// components/CMailGunLogRoute.php | |
class CMailGunLogRoute extends CEmailLogRoute { | |
protected function sendEmail($email, $subject, $message) { | |
$mail = Yii::app()->mailgun->newMessage(); | |
$mail->setFrom($this->getSentFrom()); | |
$mail->addTo($email); | |
$mail->setSubject($subject); | |
$mail->setText($message); | |
$mail->send(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// config/main.php | |
'import'=>array( | |
'application.components.*', | |
), | |
'mailgun' => array( | |
'class' => 'application.extensions.php-mailgun.MailgunYii', | |
'domain' => 'mydomain.com', | |
'key' => 'API_KEY_NUM', | |
'tags' => array('yii'), // You may also specify some Mailgun parameters | |
'enableTracking' => true, | |
), | |
'log'=>array( | |
'class'=>'CLogRouter', | |
'routes'=>array( | |
array( | |
'class'=>'CMailGunLogRoute', | |
'levels'=>'info', | |
'filter'=>'CLogFilter', | |
'emails'=>'recipient@domain.com', | |
'sentFrom'=>'sender@domain.com', | |
'subject'=>'Email Log File Message', | |
), | |
), | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// controllers/SiteController.php | |
Yii::log('Test Log Message', 'info','application'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment