Commit d638910b authored by Carsten  Rose's avatar Carsten Rose
Browse files

#4255 / Attachments fuer 'Email'

 Manual.rst: description of new options for MAIL_LOG and Report/sendmail.
 sendEmail: added new perl script.
 Report.php: $mailarr renamed to $mailConfig. convertToken() updated.
 Sendmail.php: commented mb_send_mail(). New sendEmail().
 Config.php: new options MAIL_LOG.
 Store.php: Update SUSTEM_SEND_E_MAIL
parent 7b497c32
...@@ -68,7 +68,7 @@ Preparation for Ubuntu 14.04:: ...@@ -68,7 +68,7 @@ Preparation for Ubuntu 14.04::
Preparation for Ubuntu 16.04:: Preparation for Ubuntu 16.04::
sudo apt install php7.0-intl sudo apt install php7.0-intl
sudo apt install pdftk libxrender1 file # for file upload, PDF and 'HTML to PDF' (wkhtmltopdf) sudo apt install pdftk libxrender1 file pdf2svg # for file upload, PDF and 'HTML to PDF' (wkhtmltopdf), PDF split
.. _wkhtml: .. _wkhtml:
...@@ -238,11 +238,15 @@ config.qfq.ini ...@@ -238,11 +238,15 @@ config.qfq.ini
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| DB_INDEX_QFQ | DB_INDEX_QFQ = 1 | Optional. Default: 1. | | DB_INDEX_QFQ | DB_INDEX_QFQ = 1 | Optional. Default: 1. |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| SQL_LOG | SQL_LOG=sql.log | Filename to log SQL commands: relative to <ext_dir> or absolute. | | SQL_LOG | SQL_LOG=../../sql.log | Filename to log SQL commands: relative to <ext_dir> or absolute. |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| SQL_LOG_MODE | SQL_LOG_MODE=modify | *all*: every statement will be logged - this might a lot. | | SQL_LOG_MODE | SQL_LOG_MODE=modify | *all*: every statement will be logged - this might a lot. |
| | | *modify*: log only statements who change data. | | | | *modify*: log only statements who change data. |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| MAIL_LOG | SQL_LOG=../../mail.log | Filename to log `sendEmail` commands: relative to <ext_dir> or absolute. |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| SEND_E_MAIL_OPTIONS | SEND_E_MAIL_OPTIONS="-o tls=yes" | General options. Check: http://caspian.dotconf.net/menu/Software/SendEmail |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| SHOW_DEBUG_INFO | SHOW_DEBUG_INFO=auto | FE - Possible values: yes|no|auto|download. For 'auto': If a BE User is | | SHOW_DEBUG_INFO | SHOW_DEBUG_INFO=auto | FE - Possible values: yes|no|auto|download. For 'auto': If a BE User is |
| | | logged in, a debug information will be shown on the FE. | | | | logged in, a debug information will be shown on the FE. |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
...@@ -3357,6 +3361,8 @@ Type: sendmail ...@@ -3357,6 +3361,8 @@ Type: sendmail
* *sendMailFrom* - Sender of the email. Optional: 'realname <john@doe.com>'. **Mandatory**. * *sendMailFrom* - Sender of the email. Optional: 'realname <john@doe.com>'. **Mandatory**.
* *sendMailSubject* - Subject of the email. * *sendMailSubject* - Subject of the email.
* *sendMailReplyTo* - Reply this email address. Optional: 'realname <john@doe.com>'. * *sendMailReplyTo* - Reply this email address. Optional: 'realname <john@doe.com>'.
* *sendMailAttachment* - List of files to attach to the mail. Multiple files separated by comma.
* *sendMailHeader* - Specify custom header.
* *sendMailFlagAutoSubmit* - **on|off** - If 'on' (default), the mail contains the header * *sendMailFlagAutoSubmit* - **on|off** - If 'on' (default), the mail contains the header
'Auto-Submitted: auto-send' - this suppress a) OoO replies, b) forwarding of emails. 'Auto-Submitted: auto-send' - this suppress a) OoO replies, b) forwarding of emails.
* *sendMailGrId* - Will be copied to the mailLog record. Helps to setup specific logfile queries. * *sendMailGrId* - Will be copied to the mailLog record. Helps to setup specific logfile queries.
...@@ -5224,59 +5230,59 @@ Send text emails. Every mail will be logged in the table `mailLog`. ...@@ -5224,59 +5230,59 @@ Send text emails. Every mail will be logged in the table `mailLog`.
:: ::
SELECT "t:john@doe.com|f:jane@doe.com|s:Reminder tomorrow|b:Please dont miss the meeting tomorrow" AS _sendmail SELECT "t:john@doe.com|f:jane@doe.com|s:Reminder tomorrow|b:Please dont miss the meeting tomorrow" AS _sendmail
SELECT "t:john@doe.com|f:jane@doe.com|s:Reminder tomorrow|b:Please dont miss the meeting tomorrow|a:off|g:1|x:2|y:3|z:4" AS _sendmail SELECT "t:john@doe.com|f:jane@doe.com|s:Reminder tomorrow|b:Please dont miss the meeting tomorrow|A:off|g:1|x:2|y:3|z:4" AS _sendmail
.. ..
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
|***Token** | **Parameter** |**Description** |**Required**| |***Token** | **Parameter** |**Description** |**Required**|
+============================================================+==========================================================================================+============+ +===+========================================+==================================================================================================+============+
| t | email[,email] |Comma-separated list of receiver email addresses. Optional: `realname <john@doe.com>` | yes | | f | FROM:email |**FROM**: Sender of the email. Optional: 'realname <john@doe.com>' | yes |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| f | FROM:email |Sender of the email. Optional: 'realname <john@doe.com>' | yes | | t | email[,email] |**TO**: Comma separated list of receiver email addresses. Optional: `realname <john@doe.com>` | yes |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| s | subject |Subject of the email | yes | | c | email[,email] |**CC**: Comma separated list of receiver email addresses. Optional: 'realname <john@doe.com>' | |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| b | body |Message | yes | | B | email[,email] |**BCC**: Comma separated list of receiver email addresses. Optional: 'realname <john@doe.com>' | |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| F | REPLY-TO:email |Email address to reply to (if different from sender) | | | r | REPLY-TO:email |**Reply-to**: Email address to reply to (if different from sender) | |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| a | flagAutoSubmit 'on' / 'off' |If 'on' (default), add mail header 'Auto-Submitted: auto-send' - suppress OoO replies | | | s | Subject |**Subject**: Subject of the email | yes |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| b | Body |**Body**: Message | yes |
+---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| h | Header |**Custom Header**: Separate multiple header with \r\n | |
+---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| a | Attachment |**Attachment**: Comma separated list of filenames to attach to the mail | |
+---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| A | flagAutoSubmit 'on' / 'off' |If 'on' (default), add mail header 'Auto-Submitted: auto-send' - suppress OoO replies | |
+---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| g | grId |Will be copied to the mailLog record. Helps to setup specific logfile queries | | | g | grId |Will be copied to the mailLog record. Helps to setup specific logfile queries | |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| x | xId |Will be copied to the mailLog record. Helps to setup specific logfile queries | | | x | xId |Will be copied to the mailLog record. Helps to setup specific logfile queries | |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| y | xId2 |Will be copied to the mailLog record. Helps to setup specific logfile queries | | | y | xId2 |Will be copied to the mailLog record. Helps to setup specific logfile queries | |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| z | xId3 |Will be copied to the mailLog record. Helps to setup specific logfile queries | | | z | xId3 |Will be copied to the mailLog record. Helps to setup specific logfile queries | |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+ +---+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| c | email[,email] |Comma-separated list of receiver email addresses. Optional: 'realname <john@doe.com>' | |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+
| B | mail[,email] |Comma-separated list of receiver email addresses. Optional: 'realname <john@doe.com>' | |
+------------------------------------------------------------+------------------------------------------------------------------------------------------+------------+
**Minimal Example** **Minimal Example**
:: ::
10.sql = SELECT "t:john.doe@example.com|f:company@example.com|s:Latest News|b:The new version is now available." AS _sendmail
10.sql = SELECT "john.doe@example.com|company@example.com|Latest News|The new version is now available." AS _sendmail
.. ..
This will send an email with subject *Latest News* from company@example.com to john.doe@example.com. This will send an email with subject *Latest News* from company@example.com to john.doe@example.com.
**Advanced Examples** **Advanced Examples**
:: ::
10.sql = SELECT "t:customer1@example.com,Firstname Lastname <customer2@example.com>, Firstname Lastname <customer3@example.com>|
10.sql = SELECT "customer1@example.com,Firstname Lastname <customer2@example.com>, Firstname Lastname <customer3@example.com>|company@example.com|Latest News|The new version is now available.|sales@example.com|on|101|222|ceo@example.com|backup@example.com" AS _sendmail f:company@example.com|s:Latest News|b:The new version is now available.|r:sales@example.com|A:on|g:101|x:222|c:ceo@example.com|B:backup@example.com" AS _sendmail
.. ..
This will send an email with subject *Latest News* from company@example.com to customer1, customer2 and customer3 by This will send an email with subject *Latest News* from company@example.com to customer1, customer2 and customer3 by
......
...@@ -23,6 +23,9 @@ SQL_LOG = ../../sql.log ...@@ -23,6 +23,9 @@ SQL_LOG = ../../sql.log
; all|modify|error|none ; all|modify|error|none
SQL_LOG_MODE = modify SQL_LOG_MODE = modify
;MAIL_LOG = ../../mail.log
;SEND_E_MAIL_OPTIONS = "-o ... " - check http://caspian.dotconf.net/menu/Software/SendEmail
; [auto|yes|no][,download]. 'auto': if BE User is logged in the value will be replaced by 'yes', else 'no'. Additional choose 'download'. ; [auto|yes|no][,download]. 'auto': if BE User is logged in the value will be replaced by 'yes', else 'no'. Additional choose 'download'.
SHOW_DEBUG_INFO = auto SHOW_DEBUG_INFO = auto
......
This diff is collapsed.
...@@ -374,6 +374,8 @@ const SYSTEM_SQL_LOG_FILE = '../../sql.log'; ...@@ -374,6 +374,8 @@ const SYSTEM_SQL_LOG_FILE = '../../sql.log';
const SYSTEM_SQL_LOG_MODE = 'SQL_LOG_MODE'; // Mode, which statements to log. const SYSTEM_SQL_LOG_MODE = 'SQL_LOG_MODE'; // Mode, which statements to log.
const SYSTEM_DATE_FORMAT = 'DATE_FORMAT'; const SYSTEM_DATE_FORMAT = 'DATE_FORMAT';
const SYSTEM_REDIRECT_ALL_MAIL_TO = 'REDIRECT_ALL_MAIL_TO'; const SYSTEM_REDIRECT_ALL_MAIL_TO = 'REDIRECT_ALL_MAIL_TO';
const SYSTEM_MAIL_LOG = 'MAIL_LOG';
const SYSTEM_MAIL_LOG_FILE = '../../mail.log';
const SYSTEM_SHOW_DEBUG_INFO = 'SHOW_DEBUG_INFO'; const SYSTEM_SHOW_DEBUG_INFO = 'SHOW_DEBUG_INFO';
const SYSTEM_SHOW_DEBUG_INFO_YES = 'yes'; const SYSTEM_SHOW_DEBUG_INFO_YES = 'yes';
...@@ -405,6 +407,9 @@ const SYSTEM_FORM_BUTTON_ON_CHANGE_CLASS = 'FORM_BUTTON_ON_CHANGE_CLASS'; ...@@ -405,6 +407,9 @@ const SYSTEM_FORM_BUTTON_ON_CHANGE_CLASS = 'FORM_BUTTON_ON_CHANGE_CLASS';
const SYSTEM_BASE_URL_PRINT = 'BASE_URL_PRINT'; const SYSTEM_BASE_URL_PRINT = 'BASE_URL_PRINT';
const SYSTEM_WKHTMLTOPDF = 'WKHTMLTOPDF'; const SYSTEM_WKHTMLTOPDF = 'WKHTMLTOPDF';
const SYSTEM_SEND_E_MAIL = 'sendEmail';
const SYSTEM_SEND_E_MAIL_OPTIONS = 'SEND_E_MAIL_OPTIONS';
const SYSTEM_EDIT_FORM_PAGE = 'EDIT_FORM_PAGE'; const SYSTEM_EDIT_FORM_PAGE = 'EDIT_FORM_PAGE';
// computed automatically during runtime // computed automatically during runtime
...@@ -912,7 +917,6 @@ const FE_INPUT_EXTRA_BUTTON_PASSWORD = 'extraButtonPassword'; ...@@ -912,7 +917,6 @@ const FE_INPUT_EXTRA_BUTTON_PASSWORD = 'extraButtonPassword';
const FE_INPUT_EXTRA_BUTTON_INFO = 'extraButtonInfo'; const FE_INPUT_EXTRA_BUTTON_INFO = 'extraButtonInfo';
const FE_INPUT_EXTRA_BUTTON_INFO_CLASS = 'extraButtonInfoClass'; const FE_INPUT_EXTRA_BUTTON_INFO_CLASS = 'extraButtonInfoClass';
const FE_TMP_EXTRA_BUTTON_HTML = '_extraButtonHtml'; // will be filled on the fly during building extrabutton const FE_TMP_EXTRA_BUTTON_HTML = '_extraButtonHtml'; // will be filled on the fly during building extrabutton
const FE_TMP_EXTRA_BUTTON_HTML = '_extraButtonHtml'; // will be filled on the fly during building extrabutton
const FE_CHECKBOX_CHECKED = 'checked'; const FE_CHECKBOX_CHECKED = 'checked';
const FE_CHECKBOX_UNCHECKED = 'unchecked'; const FE_CHECKBOX_UNCHECKED = 'unchecked';
const FE_RECORD_DESTINATION_TABLE = 'recordDestinationTable'; const FE_RECORD_DESTINATION_TABLE = 'recordDestinationTable';
...@@ -1059,20 +1063,24 @@ const SENDMAIL_IDX_GR_ID = 6; ...@@ -1059,20 +1063,24 @@ const SENDMAIL_IDX_GR_ID = 6;
const SENDMAIL_IDX_X_ID = 7; const SENDMAIL_IDX_X_ID = 7;
const SENDMAIL_IDX_RECEIVER_CC = 8; const SENDMAIL_IDX_RECEIVER_CC = 8;
const SENDMAIL_IDX_RECEIVER_BCC = 9; const SENDMAIL_IDX_RECEIVER_BCC = 9;
const SENDMAIL_IDX_X_ID2 = 10; const SENDMAIL_IDX_ATTACHMENT = 10;
const SENDMAIL_IDX_X_ID3 = 11; const SENDMAIL_IDX_HEADER = 11;
const SENDMAIL_IDX_SRC = 12; const SENDMAIL_IDX_X_ID2 = 12;
const SENDMAIL_IDX_X_ID3 = 13;
const SENDMAIL_IDX_SRC = 14;
const SENDMAIL_TOKEN_RECEIVER = 't'; const SENDMAIL_TOKEN_RECEIVER = 't';
const SENDMAIL_TOKEN_SENDER = 'f'; const SENDMAIL_TOKEN_SENDER = 'f';
const SENDMAIL_TOKEN_SUBJECT = 's'; const SENDMAIL_TOKEN_SUBJECT = 's';
const SENDMAIL_TOKEN_BODY = 'b'; const SENDMAIL_TOKEN_BODY = 'b';
const SENDMAIL_TOKEN_REPLY_TO = 'F'; const SENDMAIL_TOKEN_REPLY_TO = 'r';
const SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT = 'a'; const SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT = 'A';
const SENDMAIL_TOKEN_GR_ID = 'g'; const SENDMAIL_TOKEN_GR_ID = 'g';
const SENDMAIL_TOKEN_X_ID = 'x'; const SENDMAIL_TOKEN_X_ID = 'x';
const SENDMAIL_TOKEN_RECEIVER_CC = 'c'; const SENDMAIL_TOKEN_RECEIVER_CC = 'c';
const SENDMAIL_TOKEN_RECEIVER_BCC = 'B'; const SENDMAIL_TOKEN_RECEIVER_BCC = 'B';
const SENDMAIL_TOKEN_ATTACHMENT = 'a';
const SENDMAIL_TOKEN_HEADER = 'h';
const SENDMAIL_TOKEN_X_ID2 = 'y'; const SENDMAIL_TOKEN_X_ID2 = 'y';
const SENDMAIL_TOKEN_X_ID3 = 'z'; const SENDMAIL_TOKEN_X_ID3 = 'z';
const SENDMAIL_TOKEN_SRC = 'S'; const SENDMAIL_TOKEN_SRC = 'S';
......
...@@ -706,36 +706,36 @@ class Report { ...@@ -706,36 +706,36 @@ class Report {
break; break;
} }
$mailarr = explode("|", $columnValue, 3); $mailConfig = explode("|", $columnValue, 3);
// Fake values for tmp[1], tmp[2] to suppress access errors. // Fake values for tmp[1], tmp[2] to suppress access errors.
$mailarr[] = ''; $mailConfig[] = '';
$mailarr[] = ''; $mailConfig[] = '';
if (empty($mailarr[0])) { if (empty($mailConfig[0])) {
break; break;
} }
$attribute = Support::doAttribute('src', $mailarr[0]); $attribute = Support::doAttribute('src', $mailConfig[0]);
$attribute .= Support::doAttribute('alt', $mailarr[1]); $attribute .= Support::doAttribute('alt', $mailConfig[1]);
$content .= '<img ' . $attribute . '>' . $mailarr[2]; $content .= '<img ' . $attribute . '>' . $mailConfig[2];
break; break;
case "mailto": case "mailto":
// "<email address>|[Real Name]" renders to (encrypted via JS): <a href="mailto://<email address>"><email address></a> OR <a href="mailto://<email address>">[Real Name]</a> // "<email address>|[Real Name]" renders to (encrypted via JS): <a href="mailto://<email address>"><email address></a> OR <a href="mailto://<email address>">[Real Name]</a>
$mailarr = explode("|", $columnValue, 2); $mailConfig = explode("|", $columnValue, 2);
if (empty($mailarr[0])) { if (empty($mailConfig[0])) {
break; break;
} }
$t1 = explode("@", $mailarr[0], 2); $t1 = explode("@", $mailConfig[0], 2);
$content .= "<script language=javascript><!--" . chr(10); $content .= "<script language=javascript><!--" . chr(10);
if (empty($mailarr[1])) { if (empty($mailConfig[1])) {
$mailarr[1] = $mailarr[0]; $mailConfig[1] = $mailConfig[0];
} }
$content .= 'var contact = "' . substr($mailarr[1], 0, 2) . '"' . chr(10); $content .= 'var contact = "' . substr($mailConfig[1], 0, 2) . '"' . chr(10);
$content .= 'var contact1 = "' . substr($mailarr[1], 2) . '"' . chr(10); $content .= 'var contact1 = "' . substr($mailConfig[1], 2) . '"' . chr(10);
$content .= 'var email = "' . $t1[0] . '"' . chr(10); $content .= 'var email = "' . $t1[0] . '"' . chr(10);
$content .= 'var emailHost = "' . $t1[1] . '"' . chr(10); $content .= 'var emailHost = "' . $t1[1] . '"' . chr(10);
...@@ -747,56 +747,56 @@ class Report { ...@@ -747,56 +747,56 @@ class Report {
case "sendmail": case "sendmail":
// '<receiver1>,<receiver2>,...|<sender>|<subject>|<body>|<reply-to>|<flag autosubmit: on /off>' // '<receiver1>,<receiver2>,...|<sender>|<subject>|<body>|<reply-to>|<flag autosubmit: on /off>'
// $mailarr = explode("|", $columnValue); // $mailarr = explode("|", $columnValue);
$mailarr = $this->sendmailConvertToken($columnValue); $mailConfig = $this->sendmailConvertToken($columnValue);
if (count($mailarr) < 4) { if (count($mailConfig) < 4) {
throw new SyntaxReportException ("Too few parameter for sendmail: $columnValue", ERROR_TOO_FEW_PARAMETER_FOR_SENDMAIL, null, __FILE__, __LINE__, $this->fr_error); throw new SyntaxReportException ("Too few parameter for sendmail: $columnValue", ERROR_TOO_FEW_PARAMETER_FOR_SENDMAIL, null, __FILE__, __LINE__, $this->fr_error);
} }
if (!isset($mailarr[SENDMAIL_IDX_REPLY_TO])) { // if (!isset($mailarr[SENDMAIL_IDX_REPLY_TO])) {
$mailarr[SENDMAIL_IDX_REPLY_TO] = ''; // $mailarr[SENDMAIL_IDX_REPLY_TO] = '';
} // }
//
if (!isset($mailarr[SENDMAIL_IDX_FLAG_AUTO_SUBMIT])) { // if (!isset($mailarr[SENDMAIL_IDX_FLAG_AUTO_SUBMIT])) {
$mailarr[SENDMAIL_IDX_FLAG_AUTO_SUBMIT] = 'on'; // $mailarr[SENDMAIL_IDX_FLAG_AUTO_SUBMIT] = 'on';
} // }
//
if (!isset($mailarr[SENDMAIL_IDX_GR_ID])) { // if (!isset($mailarr[SENDMAIL_IDX_GR_ID])) {
$mailarr[SENDMAIL_IDX_GR_ID] = '0'; // $mailarr[SENDMAIL_IDX_GR_ID] = '0';
} // }
//
if (!isset($mailarr[SENDMAIL_IDX_X_ID])) { // if (!isset($mailarr[SENDMAIL_IDX_X_ID])) {
$mailarr[SENDMAIL_IDX_X_ID] = '0'; // $mailarr[SENDMAIL_IDX_X_ID] = '0';
} // }
//
if (!isset($mailarr[SENDMAIL_IDX_RECEIVER_CC])) { // if (!isset($mailarr[SENDMAIL_IDX_RECEIVER_CC])) {
$mailarr[SENDMAIL_IDX_RECEIVER_CC] = ''; // $mailarr[SENDMAIL_IDX_RECEIVER_CC] = '';
} // }
//
if (!isset($mailarr[SENDMAIL_IDX_RECEIVER_BCC])) { // if (!isset($mailarr[SENDMAIL_IDX_RECEIVER_BCC])) {
$mailarr[SENDMAIL_IDX_RECEIVER_BCC] = ''; // $mailarr[SENDMAIL_IDX_RECEIVER_BCC] = '';
} // }
//
if (!isset($mailarr[SENDMAIL_IDX_X_ID])) { // if (!isset($mailarr[SENDMAIL_IDX_X_ID])) {
$mailarr[SENDMAIL_IDX_X_ID] = '0'; // $mailarr[SENDMAIL_IDX_X_ID] = '0';
} // }
//
if (!isset($mailarr[SENDMAIL_IDX_X_ID2])) { // if (!isset($mailarr[SENDMAIL_IDX_X_ID2])) {
$mailarr[SENDMAIL_IDX_X_ID] = '0'; // $mailarr[SENDMAIL_IDX_X_ID] = '0';
} // }
//
if (!isset($mailarr[SENDMAIL_IDX_X_ID3])) { // if (!isset($mailarr[SENDMAIL_IDX_X_ID3])) {
$mailarr[SENDMAIL_IDX_X_ID] = '0'; // $mailarr[SENDMAIL_IDX_X_ID] = '0';
} // }
$mailarr[SENDMAIL_IDX_SRC] = "Report: T3 pageId=" . $this->store->getVar('pageId', STORE_TYPO3) . $mailConfig[SENDMAIL_IDX_SRC] = "Report: T3 pageId=" . $this->store->getVar('pageId', STORE_TYPO3) .
", T3 ttcontentId=" . $this->store->getVar('ttcontentUid', STORE_TYPO3) . ", T3 ttcontentId=" . $this->store->getVar('ttcontentUid', STORE_TYPO3) .
", Level=" . $full_level; ", Level=" . $full_level;
new Sendmail($mailarr); new Sendmail($mailConfig);
break; break;
case "vertical": case "vertical":
// '<Text>|[angle]|[width]|[height]|[tag]' , width and heigth needs a unit (px, em ,...), 'tag' might be 'div', 'span', ... // '<Text>|[angle]|[width]|[height]|[tag]' , width and height needs a unit (px, em ,...), 'tag' might be 'div', 'span', ...
$arr = explode("|", $columnValue, 5); $arr = explode("|", $columnValue, 5);
# angle # angle
...@@ -804,11 +804,11 @@ class Report { ...@@ -804,11 +804,11 @@ class Report {
# width # width
$width = $arr[2] ? $arr[2] : "1em"; $width = $arr[2] ? $arr[2] : "1em";
$mailarr = "width:$width; "; $extra = "width:$width; ";
# height # height
if ($arr[3]) { if ($arr[3]) {
$mailarr .= "height:" . $arr[3] . "; "; $extra .= "height:" . $arr[3] . "; ";
} }
# tag # tag
...@@ -864,7 +864,7 @@ class Report { ...@@ -864,7 +864,7 @@ class Report {
exec($cmd, $arr, $rc); exec($cmd, $arr, $rc);
$output = implode('<BR>', $arr); $output = implode('<br>', $arr);
if ($rc != 0) { if ($rc != 0) {
$output = $rc . " - " . $output; $output = $rc . " - " . $output;
} }
...@@ -1251,11 +1251,13 @@ class Report { ...@@ -1251,11 +1251,13 @@ class Report {
SENDMAIL_TOKEN_SUBJECT => SENDMAIL_IDX_SUBJECT, SENDMAIL_TOKEN_SUBJECT => SENDMAIL_IDX_SUBJECT,
SENDMAIL_TOKEN_BODY => SENDMAIL_IDX_BODY, SENDMAIL_TOKEN_BODY => SENDMAIL_IDX_BODY,
SENDMAIL_TOKEN_REPLY_TO => SENDMAIL_IDX_REPLY_TO, SENDMAIL_TOKEN_REPLY_TO => SENDMAIL_IDX_REPLY_TO,
SENDMAIL_TOKEN_RECEIVER_CC => SENDMAIL_IDX_RECEIVER_CC,
SENDMAIL_TOKEN_RECEIVER_BCC => SENDMAIL_IDX_RECEIVER_BCC,
SENDMAIL_TOKEN_HEADER => SENDMAIL_IDX_HEADER,
SENDMAIL_TOKEN_ATTACHMENT => SENDMAIL_IDX_ATTACHMENT,
SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT => SENDMAIL_IDX_FLAG_AUTO_SUBMIT, SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT => SENDMAIL_IDX_FLAG_AUTO_SUBMIT,
SENDMAIL_TOKEN_GR_ID => SENDMAIL_IDX_GR_ID, SENDMAIL_TOKEN_GR_ID => SENDMAIL_IDX_GR_ID,
SENDMAIL_TOKEN_X_ID => SENDMAIL_IDX_X_ID, SENDMAIL_TOKEN_X_ID => SENDMAIL_IDX_X_ID,
SENDMAIL_TOKEN_RECEIVER_CC => SENDMAIL_IDX_RECEIVER_CC,
SENDMAIL_TOKEN_RECEIVER_BCC => SENDMAIL_IDX_RECEIVER_BCC,
SENDMAIL_TOKEN_SRC => SENDMAIL_IDX_SRC, SENDMAIL_TOKEN_SRC => SENDMAIL_IDX_SRC,
SENDMAIL_TOKEN_X_ID2 => SENDMAIL_IDX_X_ID2, SENDMAIL_TOKEN_X_ID2 => SENDMAIL_IDX_X_ID2,
SENDMAIL_TOKEN_X_ID3 => SENDMAIL_IDX_X_ID3 SENDMAIL_TOKEN_X_ID3 => SENDMAIL_IDX_X_ID3
...@@ -1267,7 +1269,7 @@ class Report { ...@@ -1267,7 +1269,7 @@ class Report {
} }
$segments = explode('|', $data); $segments = explode('|', $data);
$arr = ['', '', '', '', '', '', '', '', '', '', '', '', '']; $arr = ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''];
foreach ($segments AS $line) { foreach ($segments AS $line) {
$piece = explode(':', $line, 2); $piece = explode(':', $line, 2);
......
...@@ -11,6 +11,11 @@ require_once(__DIR__ . '/../store/Store.php'); ...@@ -11,6 +11,11 @@ require_once(__DIR__ . '/../store/Store.php');
class Sendmail { class Sendmail {
/**
* @var Store
*/
private $store = null;
/** /**
* Sends a mail as specified in $mailarr. * Sends a mail as specified in $mailarr.
* If there is no receiver specified as 'TO': no mail is sent. This is ok and no error. * If there is no receiver specified as 'TO': no mail is sent. This is ok and no error.
...@@ -28,71 +33,169 @@ class Sendmail { ...@@ -28,71 +33,169 @@ class Sendmail {
* SENDMAIL_IDX_GR_ID optional: integer * SENDMAIL_IDX_GR_ID optional: integer
* SENDMAIL_IDX_X_ID optional: integer * SENDMAIL_IDX_X_ID optional: integer
* *
* @param $mailarr * @param $mailConfig
* *
* @throws UserFormException * @throws UserFormException
*/ */
public function __construct(array $mailarr) { public function __construct(array $mailConfig) {
$addBody = '';
// If there is no 'Receiver': do not send a mail. // If there is no 'Receiver': do not send a mail.
if (!isset($mailarr[SENDMAIL_IDX_RECEIVER]) || $mailarr[SENDMAIL_IDX_RECEIVER] === '') { if (!isset($mailConfig[SENDMAIL_IDX_RECEIVER]) || $mailConfig[SENDMAIL_IDX_RECEIVER] === '') {
return; return;
} }
if (count($mailarr) < 4 || $mailarr[SENDMAIL_IDX_SENDER] === '' || $mailarr[SENDMAIL_IDX_SUBJECT] === '' || $mailarr[SENDMAIL_IDX_BODY] === '') { if (count($mailConfig) < 4 || $mailConfig[SENDMAIL_IDX_SENDER] === '' || $mailConfig[SENDMAIL_IDX_SUBJECT] === '' || $mailConfig[SENDMAIL_IDX_BODY] === '') {
throw new UserFormException("Error sendmail missing one of: receiver, sender, subject or body", ERROR_SENDMAIL_MISSING_VALUE); throw new UserFormException("Error sendmail missing one of: receiver, sender, subject or body", ERROR_SENDMAIL_MISSING_VALUE);
} }
$store = Store::getInstance(''); $this->store = Store::getInstance('');
$redirectAllMail = $store->getVar(SYSTEM_REDIRECT_ALL_MAIL_TO, STORE_SYSTEM);
$redirectAllMail = $this->store->getVar(SYSTEM_REDIRECT_ALL_MAIL_TO, STORE_SYSTEM);
if ($redirectAllMail !== false) { if ($redirectAllMail !== false) {
$addBody .= "All QFQ outgoing mails are catched and redirected to you." . PHP_EOL . "Original receiver:" . PHP_EOL; $addBody = "All QFQ outgoing mails are catched and redirected to you." . PHP_EOL . "Original receiver:" . PHP_EOL;
$addBody .= 'TO: ' . $mailarr[SENDMAIL_IDX_RECEIVER] . PHP_EOL; $addBody .= 'TO: ' . $mailConfig[SENDMAIL_IDX_RECEIVER] . PHP_EOL;
$addBody .= 'CC: ' . $mailarr[SENDMAIL_IDX_RECEIVER_CC] . PHP_EOL; $addBody .= 'CC: ' . $mailConfig[SENDMAIL_IDX_RECEIVER_CC] . PHP_EOL;
$addBody .= 'BCC: ' . $mailarr[SENDMAIL_IDX_RECEIVER_BCC] . PHP_EOL; $addBody .= 'BCC: ' . $mailConfig[SENDMAIL_IDX_RECEIVER_BCC] . PHP_EOL;
$addBody .= PHP_EOL . "==========================================" . PHP_EOL . PHP_EOL; $addBody .= PHP_EOL . "==========================================" . PHP_EOL . PHP_EOL;
$mailarr[SENDMAIL_IDX_RECEIVER] = $redirectAllMail; $mailConfig[SENDMAIL_IDX_BODY] = $addBody . $mailConfig[SENDMAIL_IDX_BODY];
$mailarr[SENDMAIL_IDX_RECEIVER_CC] = '';
$mailarr[SENDMAIL_IDX_RECEIVER_BCC] = ''; $mailConfig[SENDMAIL_IDX_RECEIVER] = $redirectAllMail;
$mailConfig[SENDMAIL_IDX_RECEIVER_CC] = '';
$mailConfig[SENDMAIL_IDX_RECEIVER_BCC] = '';
}
if (empty($mailConfig[SENDMAIL_IDX_FLAG_AUTO_SUBMIT]) || $mailConfig[SENDMAIL_IDX_FLAG_AUTO_SUBMIT] === '') {
$mailConfig[SENDMAIL_IDX_FLAG_AUTO_SUBMIT] = 'on';
}
// $header = $this->buildHeader($mailarr);
// if (!(mb_send_mail($mailarr[SENDMAIL_IDX_RECEIVER], $mailarr[SENDMAIL_IDX_SUBJECT], $addBody . $mailarr[SENDMAIL_IDX_BODY], $header, "-f " . $mailarr[SENDMAIL_IDX_SENDER]))) {
// throw new UserFormException("Error sendmail failed.", ERROR_SENDMAIL);
// }
$this->sendEmail($mailConfig);
$this->mailLog($mailConfig);
}
/**
* Use the programm 'sendEmail' - http://caspian.dotconf.net/menu/Software/SendEmail
*
* @param array $mailConfig
* @throws CodeException
* @throws UserFormException
*/
private function sendEmail(array $mailConfig) {
$args = array();
foreach ($mailConfig as $key => $value) {