Commit 6b02d3a4 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Maillog: fixed trouble when logging mails with attachments.

parent 6ea7ab04
Pipeline #1671 passed with stage
in 2 minutes and 8 seconds
......@@ -34,6 +34,7 @@ class OnArray {
* @return string
*/
public static function toString(array $dataArray, $keyValueGlue = '=', $rowGlue = '&', $encloseValue = '') {
if (count($dataArray) === 0) {
return '';
}
......
......@@ -69,10 +69,10 @@ class SendMail {
if (!empty($redirectAllMail)) {
$addBody = "All QFQ outgoing mails are caught and redirected to you." . PHP_EOL . "Original receiver(s) are ..." . PHP_EOL;
$addBody .= 'TO: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER]??'') . PHP_EOL;
$addBody .= 'CC: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER_CC]??'') . PHP_EOL;
$addBody .= 'BCC: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER_BCC]??'') . PHP_EOL;
$addBody .= 'SENDER: ' . ($mailConfig[SENDMAIL_TOKEN_SENDER]??'') . PHP_EOL;
$addBody .= 'TO: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER] ?? '') . PHP_EOL;
$addBody .= 'CC: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER_CC] ?? '') . PHP_EOL;
$addBody .= 'BCC: ' . ($mailConfig[SENDMAIL_TOKEN_RECEIVER_BCC] ?? '') . PHP_EOL;
$addBody .= 'SENDER: ' . ($mailConfig[SENDMAIL_TOKEN_SENDER] ?? '') . PHP_EOL;
$addBody .= PHP_EOL . "==========================================" . PHP_EOL . PHP_EOL;
// Check if the given body is a HTML body.
......@@ -238,13 +238,13 @@ class SendMail {
$output = Support::qfqExec($cmd, $rc);
if($rc!=0){
if(!is_file($sendEmail) || !is_readable($sendEmail)){
if ($rc != 0) {
if (!is_file($sendEmail) || !is_readable($sendEmail)) {
throw new UserFormException(json_encode([ERROR_MESSAGE_TO_USER => "Command 'sendEmail' not found."
, ERROR_MESSAGE_SUPPORT => $sendEmail]), ERROR_SENDMAIL);
}
if(!is_executable($sendEmail)){
if (!is_executable($sendEmail)) {
throw new UserFormException(json_encode([ERROR_MESSAGE_TO_USER => "Command 'sendEmail' not executable."
, ERROR_MESSAGE_SUPPORT => $sendEmail]), ERROR_SENDMAIL);
}
......@@ -266,8 +266,8 @@ class SendMail {
* Creates a new MailLog Record based on $mailArr / $header.
*
* @param array $mailConfig
*
* @param string $attachmentsLine
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
......@@ -277,12 +277,17 @@ class SendMail {
$log = array();
$attachments = '';
if (!empty($mailConfig[SENDMAIL_TOKEN_ATTACHMENT]) && is_array($mailConfig[SENDMAIL_TOKEN_ATTACHMENT])) {
$attachments = OnArray::toString($mailConfig[SENDMAIL_TOKEN_ATTACHMENT]);
}
$header = 'OoO:' . $mailConfig[SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT];
if (!empty($mailConfig[SENDMAIL_TOKEN_HEADER])) {
$header .= PHP_EOL . 'Custom: ' . $mailConfig[SENDMAIL_TOKEN_HEADER];
}
if (!empty($mailConfig[SENDMAIL_TOKEN_ATTACHMENT])) {
$header .= PHP_EOL . 'Attachment: ' . $mailConfig[SENDMAIL_TOKEN_ATTACHMENT];
$header .= PHP_EOL . 'Attachment: ' . $attachments;
}
// Log
......
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