From 1dedcb373c0f3cdbe8c8a5060bf7533d42920371 Mon Sep 17 00:00:00 2001 From: roberto Date: Wed, 26 Sep 2012 13:57:37 +0000 Subject: [PATCH] YiiMail -> log del envio de swiftMailer git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@34 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d --- www/protected/extensions/yii-mail/YiiMail.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/www/protected/extensions/yii-mail/YiiMail.php b/www/protected/extensions/yii-mail/YiiMail.php index 038a774..0978b58 100644 --- a/www/protected/extensions/yii-mail/YiiMail.php +++ b/www/protected/extensions/yii-mail/YiiMail.php @@ -97,6 +97,9 @@ class YiiMail extends CApplicationComponent */ protected $mailer; + + protected $logger; + private static $registeredScripts = false; /** @@ -128,9 +131,12 @@ class YiiMail extends CApplicationComponent * @see batchSend() */ public function send(YiiMailMessage $message, &$failedRecipients = null) { + $counter = 0; if ($this->logging===true) self::log($message); - if ($this->dryRun===true) return count($message->to); - else return $this->getMailer()->send($message->message, $failedRecipients); + if ($this->dryRun===true) $counter = count($message->to); + else $counter = $this->getMailer()->send($message->message, $failedRecipients); + if ($this->logging===true) Yii::log(CVarDumper::dumpAsString($this->logger->dump()), CLogger::LEVEL_INFO, 'ext.yii-mail.YiiMail'); + return $counter; } /** @@ -225,6 +231,11 @@ class YiiMail extends CApplicationComponent public function getMailer() { if ($this->mailer===null) $this->mailer = Swift_Mailer::newInstance($this->getTransport()); + + if ($this->logging===true) { + $this->logger = new Swift_Plugins_Loggers_ArrayLogger(); + $this->mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($this->logger)); + } return $this->mailer; }