Index: install/install_schema.sql =================================================================== --- install/install_schema.sql (revision 14860) +++ install/install_schema.sql (working copy) @@ -76,6 +76,7 @@ SendRetries int(10) unsigned NOT NULL DEFAULT '0', LastSendRetry int(10) unsigned DEFAULT NULL, MailingId int(10) unsigned NOT NULL DEFAULT '0', + LogData text, PRIMARY KEY (EmailQueueId), KEY LastSendRetry (LastSendRetry), KEY SendRetries (SendRetries), Index: install/upgrades.sql =================================================================== --- install/upgrades.sql (revision 14860) +++ install/upgrades.sql (working copy) @@ -2377,4 +2377,6 @@ INSERT INTO Permissions VALUES(DEFAULT, 'CATEGORY.REVISION.ADD', 11, 1, 0, 1); INSERT INTO Permissions VALUES(DEFAULT, 'CATEGORY.REVISION.HISTORY.VIEW', 11, 1, 0, 1); -INSERT INTO Permissions VALUES(DEFAULT, 'CATEGORY.REVISION.HISTORY.RESTORE', 11, 1, 0, 1); \ No newline at end of file +INSERT INTO Permissions VALUES(DEFAULT, 'CATEGORY.REVISION.HISTORY.RESTORE', 11, 1, 0, 1); + +ALTER TABLE EmailQueue ADD `LogData` TEXT; \ No newline at end of file Index: kernel/utility/email_send.php =================================================================== --- kernel/utility/email_send.php (revision 14860) +++ kernel/utility/email_send.php (working copy) @@ -118,7 +118,14 @@ */ var $smtpFeatures = Array(); + /** + * Stores log data. + * @var array + * @access private + */ + var $_logData = Array(); + public function __construct() { parent::__construct(); @@ -1132,6 +1139,7 @@ ); $this->SetCharset(null, true); + $this->_logData = Array(); } /** @@ -2002,6 +2010,7 @@ 'SendRetries' => 0, 'LastSendRetry' => 0, 'MailingId' => (int)$immediate_send, + 'LogData' => serialize($this->_logData), ); $fields_hash['MessageHeaders'] = serialize($message_headers); $fields_hash['MessageBody'] =& $message_body; @@ -2017,4 +2026,13 @@ return $immediate_send !== true ? true : false; } + /** + * Sets log data + * + * @param string $log_data + */ + function setLogData($log_data) + { + $this->_logData = $log_data; + } } \ No newline at end of file Index: units/helpers/mailing_list_helper.php =================================================================== --- units/helpers/mailing_list_helper.php (revision 14860) +++ units/helpers/mailing_list_helper.php (working copy) @@ -55,7 +55,6 @@ // 3. set recipient specific fields $esender->SetTo($email, $email); - $esender->Deliver(null, $mailing_id, false); // 4. write to log $log_fields_hash = Array ( @@ -65,8 +64,9 @@ 'timestamp' => adodb_mktime(), 'EventParams' => serialize( Array ('MailingId' => $mailing_id) ), ); + $esender->setLogData($log_fields_hash); - $this->Conn->doInsert($log_fields_hash, TABLE_PREFIX . 'EmailLog'); + $esender->Deliver(null, $mailing_id, false); } /** @@ -80,7 +80,7 @@ { $is_root = true; $email_address = $name = ''; - + if ( $mailing_data['PortalUserId'] > 0 ) { $sender =& $this->Application->recallObject('u.-item', null, Array ('skip_autoload' => true)); /* @var $sender UsersItem */ @@ -271,6 +271,9 @@ WHERE EmailQueueId = ' . $messages[$i]['EmailQueueId']; $this->Conn->Query($sql); + // add emal log record + $this->Conn->doInsert(unserialize($messages[$i]['LogData']), TABLE_PREFIX . 'EmailLog'); + $mailing_id = $messages[$i]['MailingId']; if (!array_key_exists($mailing_id, $mailing_totals)) { $mailing_totals[$mailing_id] = 0;