Index: branches/5.3.x/core/install/english.lang
===================================================================
diff -u -r15938 -r15944
--- branches/5.3.x/core/install/english.lang (.../english.lang) (revision 15938)
+++ branches/5.3.x/core/install/english.lang (.../english.lang) (revision 15944)
@@ -417,6 +417,7 @@
RW5hYmxl
RW5hYmxlZA==
RW5hYmxlIENhY2hpbmcgZm9yIHRoaXMgU2VjdGlvbg==
+ RXJyb3IgTWVzc2FnZQ==
RXJyb3IgVGFn
RXN0aW1hdGVkIFRpbWU=
RXZlbnQ=
@@ -906,6 +907,7 @@
Rm9yZXZlciAobmV2ZXIgZGVsZXRlZCBhdXRvbWF0aWNhbGx5KQ==
RS1tYWlsIFN1YmplY3Q=
RS1tYWlsIFRlbXBsYXRlcw==
+ RXJyb3I=
RXZlcnlvbmU=
RXhhY3Q=
RXhwaXJlZA==
@@ -969,6 +971,7 @@
U2F0dXJkYXk=
c2Vjb25kKHMp
U2VtaS1jb2xvbg==
+ U2VudA==
U2VwdGVtYmVy
U2lsZW50
U3BhY2U=
Index: branches/5.3.x/core/kernel/utility/email.php
===================================================================
diff -u -r15938 -r15944
--- branches/5.3.x/core/kernel/utility/email.php (.../email.php) (revision 15938)
+++ branches/5.3.x/core/kernel/utility/email.php (.../email.php) (revision 15944)
@@ -1,6 +1,6 @@
logData = array();
+
$this->fromEmail = $this->fromName = '';
$this->Application->removeObject('u.email-from');
@@ -233,14 +242,32 @@
$this->_processRecipients();
$this->_changeLanguage(false);
+ if ( $this->_storeEmailLog() ) {
+ // 1. prepare log
+ $this->logData = Array (
+ 'From' => $this->fromName . ' (' . $this->fromEmail . ')',
+ 'To' => $this->toName . ' (' . $this->toEmail . ')',
+ 'OtherRecipients' => serialize($this->recipients),
+ 'Status' => EmailLogStatus::SENT,
+ 'ErrorMessage' => '',
+ 'SentOn' => TIMENOW,
+ 'TemplateName' => $this->emailTemplate->GetDBField('TemplateName'),
+ 'EventType' => $this->emailTemplate->GetDBField('Type'),
+ 'EventParams' => serialize($this->_getCustomParams()),
+ 'ToUserId' => $this->recipientUserId,
+ 'ItemPrefix' => $this->getItemPrefix(),
+ 'ItemId' => isset($this->params['item_id']) ? $this->params['item_id'] : null,
+ );
+
+ $this->params['email_access_key'] = $this->_generateAccessKey();
+ }
+
// 1. set headers
try {
$message_headers = $this->_getHeaders();
}
catch ( Exception $e ) {
- trigger_error('Error parsing e-mail message headers', E_USER_WARNING);
-
- return false;
+ return $this->setError('Error parsing e-mail message headers');
}
$message_subject = isset($message_headers['Subject']) ? $message_headers['Subject'] : 'Mail message';
@@ -251,22 +278,7 @@
}
if ( $this->_storeEmailLog() ) {
- // 2. prepare log
- $log_fields_hash = Array (
- 'From' => $this->fromName . ' (' . $this->fromEmail . ')',
- 'To' => $this->toName . ' (' . $this->toEmail . ')',
- 'OtherRecipients' => serialize($this->recipients),
- 'Subject' => $message_subject,
- 'SentOn' => TIMENOW,
- 'TemplateName' => $this->emailTemplate->GetDBField('TemplateName'),
- 'EventType' => $this->emailTemplate->GetDBField('Type'),
- 'EventParams' => serialize($this->_getCustomParams()),
- 'ToUserId' => $this->recipientUserId,
- 'ItemPrefix' => $this->getItemPrefix(),
- 'ItemId' => isset($this->params['item_id']) ? $this->params['item_id'] : null,
- );
-
- $this->params['email_access_key'] = $this->_generateAccessKey($log_fields_hash);
+ $this->logData['Subject'] = $message_subject;
}
// 3. set body
@@ -275,15 +287,11 @@
$plain_message_body = $this->_getMessageBody(false);
}
catch ( Exception $e ) {
- trigger_error('Error parsing e-mail message body', E_USER_WARNING);
-
- return false;
+ return $this->setError('Error parsing e-mail message body');
}
if ( $html_message_body === false && $plain_message_body === false ) {
- trigger_error('Message template is empty (maybe after parsing).', E_USER_WARNING);
-
- return false;
+ return $this->setError('Message template is empty (maybe after parsing).');
}
if ( $html_message_body !== false ) {
@@ -298,10 +306,10 @@
if ( $this->_storeEmailLog() ) {
// 4. set log
- $log_fields_hash['HtmlBody'] = $html_message_body;
- $log_fields_hash['TextBody'] = $plain_message_body;
- $log_fields_hash['AccessKey'] = $this->params['email_access_key'];
- $this->sender->setLogData($log_fields_hash);
+ $this->logData['HtmlBody'] = $html_message_body;
+ $this->logData['TextBody'] = $plain_message_body;
+ $this->logData['AccessKey'] = $this->params['email_access_key'];
+ $this->sender->setLogData($this->logData);
}
$delivery = isset($this->params['delivery']) ? $this->params['delivery'] : $this->Application->ConfigValue('EmailDelivery');
@@ -339,19 +347,36 @@
}
/**
+ * Marks e-mail sending as failed.
+ *
+ * @param string $error_message Error message.
+ *
+ * @return boolean
+ */
+ protected function setError($error_message)
+ {
+ if ( $this->_storeEmailLog() ) {
+ $this->logData['Status'] = EmailLogStatus::ERROR;
+ $this->logData['ErrorMessage'] = $error_message;
+ $this->Conn->doInsert($this->logData, TABLE_PREFIX . 'EmailLog');
+ }
+
+ return false;
+ }
+
+ /**
* Generates access key for accessing e-mail later
*
- * @param Array $log_fields_hash
* @return string
* @access protected
*/
- protected function _generateAccessKey($log_fields_hash)
+ protected function _generateAccessKey()
{
$ret = '';
$use_fields = Array ('From', 'To', 'Subject');
foreach ($use_fields as $use_field) {
- $ret .= $log_fields_hash[$use_field] . ':';
+ $ret .= $this->logData[$use_field] . ':';
}
return md5($ret . microtime(true));
Index: branches/5.3.x/core/kernel/constants.php
===================================================================
diff -u -r15928 -r15944
--- branches/5.3.x/core/kernel/constants.php (.../constants.php) (revision 15928)
+++ branches/5.3.x/core/kernel/constants.php (.../constants.php) (revision 15944)
@@ -1,6 +1,6 @@
_logData ) {
+ $this->_logData['Status'] = EmailLogStatus::ERROR;
+ $this->_logData['ErrorMessage'] = $error_msg;
+ $this->Conn->doInsert($this->_logData, TABLE_PREFIX . 'EmailLog');
}
else {
- if ( $this->Application->isDebugMode() ) {
- $this->Application->Debugger->appendTrace();
+ if ($fatal) {
+ throw new Exception($error_msg);
}
+ else {
+ if ( $this->Application->isDebugMode() ) {
+ $this->Application->Debugger->appendTrace();
+ }
- trigger_error($error_msg, E_USER_WARNING);
+ trigger_error($error_msg, E_USER_WARNING);
+ }
}
return false;
Index: branches/5.3.x/core/install/upgrades.sql
===================================================================
diff -u -r15938 -r15944
--- branches/5.3.x/core/install/upgrades.sql (.../upgrades.sql) (revision 15938)
+++ branches/5.3.x/core/install/upgrades.sql (.../upgrades.sql) (revision 15944)
@@ -2955,3 +2955,7 @@
ADD ItemId INT(11) DEFAULT NULL;
DELETE FROM UserPersistentSessionData WHERE VariableName = 'email-log[Default]columns_.';
+
+ALTER TABLE EmailLog
+ ADD Status TINYINT NOT NULL DEFAULT '1' AFTER TextBody,
+ ADD ErrorMessage VARCHAR(255) NOT NULL DEFAULT '' AFTER Status;
Index: branches/5.3.x/core/units/logs/email_logs/email_logs_config.php
===================================================================
diff -u -r15938 -r15944
--- branches/5.3.x/core/units/logs/email_logs/email_logs_config.php (.../email_logs_config.php) (revision 15938)
+++ branches/5.3.x/core/units/logs/email_logs/email_logs_config.php (.../email_logs_config.php) (revision 15944)
@@ -1,6 +1,6 @@
Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
'HtmlBody' => Array ('type' => 'string', 'default' => NULL),
'TextBody' => Array ('type' => 'string', 'default' => NULL),
+ 'Status' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (
+ EmailLogStatus::SENT => 'la_opt_Sent',
+ EmailLogStatus::ERROR => 'la_opt_Error'
+ ), 'use_phrases' => 1, 'not_null' => 1, 'default' => EmailLogStatus::SENT
+ ),
+ 'ErrorMessage' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
'SentOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
'TemplateName' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
'EventType' => Array (
@@ -124,6 +132,8 @@
'Subject' => Array ('filter_block' => 'grid_like_filter', 'width' => 200),
'TemplateName' => Array ('filter_block' => 'grid_like_filter', 'width' => 170),
'EventType' => Array ('title' => 'column:la_fld_Type', 'filter_block' => 'grid_options_filter', 'width' => 60),
+ 'Status' => Array ('filter_block' => 'grid_options_filter', 'width' => 100),
+ 'ErrorMessage' => Array ('filter_block' => 'grid_like_filter', 'width' => 200),
'SentOn' => Array ('title' => 'la_prompt_SentOn', 'filter_block' => 'grid_date_range_filter', 'width' => 145),
// 'EventParams' => Array ('title' => 'la_col_EventParams', 'filter_block' => 'grid_like_filter'),
'ItemPrefix' => Array('filter_block' => 'grid_options_filter'),
Index: branches/5.3.x/core/admin_templates/logs/email_logs/email_log_edit.tpl
===================================================================
diff -u -r15938 -r15944
--- branches/5.3.x/core/admin_templates/logs/email_logs/email_log_edit.tpl (.../email_log_edit.tpl) (revision 15938)
+++ branches/5.3.x/core/admin_templates/logs/email_logs/email_log_edit.tpl (.../email_log_edit.tpl) (revision 15944)
@@ -89,6 +89,12 @@
+
+
+
+
+
+