diff --git a/extension/Source/core/helper/OnArray.php b/extension/Source/core/helper/OnArray.php index 3181b3cadff6181193ae8e9592767971102237cf..32076c1503181385fe5742624c3ffe81210fef3d 100644 --- a/extension/Source/core/helper/OnArray.php +++ b/extension/Source/core/helper/OnArray.php @@ -34,6 +34,7 @@ class OnArray { * @return string */ public static function toString(array $dataArray, $keyValueGlue = '=', $rowGlue = '&', $encloseValue = '') { + if (count($dataArray) === 0) { return ''; } diff --git a/extension/Source/core/report/SendMail.php b/extension/Source/core/report/SendMail.php index bf86a631ce9652cf9562d38c1189432793e8f7de..10d42c9ad64c422547aab6263c7f15805459a136 100644 --- a/extension/Source/core/report/SendMail.php +++ b/extension/Source/core/report/SendMail.php @@ -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