Commit 04511e82 authored by Carsten  Rose's avatar Carsten Rose
Browse files

formEditor.sql: increase MailLog.attach from 255 to 1024.

Sendmail.php: log attachments in MailLog too.
parent 71606b6e
......@@ -90,6 +90,11 @@ $UPDATE_ARRAY = array(
"ALTER TABLE `MailLog` ADD `xId2` INT NOT NULL AFTER `xId`, ADD `xId3` INT NOT NULL AFTER `xId2`",
],
'0.25.7' => [
"ALTER TABLE `MailLog` CHANGE `attach` `attach` VARCHAR(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''",
],
);
......
......@@ -84,20 +84,23 @@ class Sendmail {
// throw new UserFormException("Error sendmail failed.", ERROR_SENDMAIL);
// }
$this->sendEmail($mailConfig);
$this->mailLog($mailConfig);
$attachmentsLine = $this->sendEmail($mailConfig);
$this->mailLog($mailConfig, $attachmentsLine);
}
/**
* Use the programm 'sendEmail' - http://caspian.dotconf.net/menu/Software/SendEmail
*
* @param array $mailConfig
* @return string
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
private function sendEmail(array $mailConfig) {
$args = array();
$attachments = array();
$attachmentsLine = '';
foreach ($mailConfig as $key => $value) {
if (is_array($value)) {
......@@ -151,7 +154,8 @@ class Sendmail {
// }
$attachments = $this->attachmentsBuild($mailConfig[SENDMAIL_IDX_ATTACHMENT]);
if (!empty($attachments)) {
$args[] = '-a ' . implode(' -a ', $attachments);
$attachmentsLine = '-a ' . implode(' -a ', $attachments);
$args[] = $attachmentsLine;
}
}
......@@ -189,6 +193,8 @@ class Sendmail {
}
HelperFile::cleanTempFiles($attachments);
return $attachmentsLine;
}
/**
......@@ -229,7 +235,7 @@ class Sendmail {
* @throws CodeException
* @throws DbException
*/
private function mailLog(array $mailConfig) {
private function mailLog(array $mailConfig, $attachmentsLine = '') {
$log = array();
......@@ -247,6 +253,7 @@ class Sendmail {
$log[] = $mailConfig[SENDMAIL_IDX_SUBJECT];
$log[] = $mailConfig[SENDMAIL_IDX_BODY];
$log[] = $header;
$log[] = $attachmentsLine;
$log[] = empty($mailConfig[SENDMAIL_IDX_GR_ID]) ? 0 : $mailConfig[SENDMAIL_IDX_GR_ID];
$log[] = empty($mailConfig[SENDMAIL_IDX_X_ID]) ? 0 : $mailConfig[SENDMAIL_IDX_X_ID];
$log[] = empty($mailConfig[SENDMAIL_IDX_X_ID2]) ? 0 : $mailConfig[SENDMAIL_IDX_X_ID2];
......@@ -254,7 +261,7 @@ class Sendmail {
$log[] = empty($mailConfig[SENDMAIL_IDX_SRC]) ? 0 : $mailConfig[SENDMAIL_IDX_SRC];
$db = new Database();
$db->sql('INSERT INTO MailLog (`receiver`, `sender`, `subject`, `body`, `header`, `grId`, `xId`, `xId2`, `xId3`, `src`, `modified`, `created`) VALUES ( ?, ? , ? , ? ,?, ?, ? ,?, ?, ?, NOW(), NOW() )', ROW_REGULAR, $log);
$db->sql('INSERT INTO MailLog (`receiver`, `sender`, `subject`, `body`, `header`, `attach`, `grId`, `xId`, `xId2`, `xId3`, `src`, `modified`, `created`) VALUES ( ?, ? , ? , ? ,?, ?, ? ,?, ?, ?, ?, NOW(), NOW() )', ROW_REGULAR, $log);
}
......
......@@ -357,20 +357,20 @@ VALUES
#DROP TABLE IF EXISTS `MailLog`;
CREATE TABLE IF NOT EXISTS `MailLog` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`grId` INT(11) NOT NULL DEFAULT '0',
`xId` INT(11) NOT NULL DEFAULT '0',
`xId2` INT(11) NOT NULL DEFAULT '0',
`xId3` INT(11) NOT NULL DEFAULT '0',
`receiver` TEXT NOT NULL,
`sender` VARCHAR(255) NOT NULL DEFAULT '',
`subject` VARCHAR(255) NOT NULL DEFAULT '',
`body` TEXT NOT NULL,
`header` VARCHAR(255) NOT NULL DEFAULT '',
`attach` VARCHAR(255) NOT NULL DEFAULT '',
`src` VARCHAR(255) NOT NULL DEFAULT '',
`modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`id` INT(11) NOT NULL AUTO_INCREMENT,
`grId` INT(11) NOT NULL DEFAULT '0',
`xId` INT(11) NOT NULL DEFAULT '0',
`xId2` INT(11) NOT NULL DEFAULT '0',
`xId3` INT(11) NOT NULL DEFAULT '0',
`receiver` TEXT NOT NULL,
`sender` VARCHAR(255) NOT NULL DEFAULT '',
`subject` VARCHAR(255) NOT NULL DEFAULT '',
`body` TEXT NOT NULL,
`header` VARCHAR(255) NOT NULL DEFAULT '',
`attach` VARCHAR(1024) NOT NULL DEFAULT '',
`src` VARCHAR(255) NOT NULL DEFAULT '',
`modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment