|
From: <gem...@li...> - 2012-06-27 11:59:27
|
Revision: 792
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=792&view=rev
Author: matijsdejong
Date: 2012-06-27 11:59:17 +0000 (Wed, 27 Jun 2012)
Log Message:
-----------
Cron job now continues trying to send e-mails even after an error was encountered.
Modified Paths:
--------------
trunk/library/classes/Gems/Default/CronAction.php
trunk/library/classes/Gems/Email/TemplateMailer.php
Modified: trunk/library/classes/Gems/Default/CronAction.php
===================================================================
--- trunk/library/classes/Gems/Default/CronAction.php 2012-06-27 11:34:34 UTC (rev 791)
+++ trunk/library/classes/Gems/Default/CronAction.php 2012-06-27 11:59:17 UTC (rev 792)
@@ -162,7 +162,8 @@
$model = $this->loader->getTracker()->getTokenModel();
$mailer = new Gems_Email_TemplateMailer($this->escort);
-
+ $mailer->continueOnError = true;
+
// $mailer->setDefaultTransport(new MUtil_Mail_Transport_EchoLog());
$jobs = $this->db->fetchAll("SELECT * FROM gems__mail_jobs WHERE gmj_active = 1");
Modified: trunk/library/classes/Gems/Email/TemplateMailer.php
===================================================================
--- trunk/library/classes/Gems/Email/TemplateMailer.php 2012-06-27 11:34:34 UTC (rev 791)
+++ trunk/library/classes/Gems/Email/TemplateMailer.php 2012-06-27 11:59:17 UTC (rev 792)
@@ -49,7 +49,14 @@
const MAIL_TLS = 2;
/**
+ * Should the mailer continue sending mails, even when it encounters errors?
*
+ * @var boolean
+ */
+ public $continueOnError = false;
+
+ /**
+ *
* @var Zend_Mail_Transport
*/
protected $defaultTransport = null;
@@ -59,6 +66,11 @@
*/
protected $escort;
+ /**
+ * Feedback messages for this action.
+ *
+ * @var array of string
+ */
protected $messages = array();
private $_changeDate;
@@ -238,6 +250,7 @@
$send = array();
$scount = 0;
$ucount = 0;
+ $result = true;
foreach ($tokensData as $tokenData) {
// Should this token be mailed?
@@ -249,11 +262,15 @@
if ($message = $this->processMail($tokenData)) {
$this->addMessage($this->escort->_('Mail failed to send.'));
$this->addMessage($message);
- return false;
+ $result = true;
+ if (! $this->continueOnError) {
+ break;
+ }
+ } else {
+ $send[$tokenData['grs_email']] = true;
+ $scount++;
+ $ucount++;
}
- $send[$tokenData['grs_email']] = true;
- $scount++;
- $ucount++;
} elseif ($updateAll) {
$this->updateToken($tokenData);
@@ -266,7 +283,7 @@
$this->addMessage(sprintf($this->escort->_('Sent %d e-mails, updated %d tokens.'), $scount, $ucount));
}
- return true;
+ return $result;
}
/**
@@ -335,12 +352,12 @@
MUtil_Echo::r($to, $to_name);
MUtil_Echo::r($from, $from_name);
}
-
+
if (!$this->bounceCheck()) {
$validate = new Zend_Validate_EmailAddress();
-
+
if (!$validate->isValid($to)) {
- return "Invalid e-mail address {$to}";
+ return sprintf($this->escort->_("Invalid e-mail address '%s'."), $to);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|