diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index 9c7c2bfd..e62985c2 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -25671,21 +25671,25 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p $bccRecipients[] = new EmailRecipient($bcc3, $bcc3); } - // This will build the mail with phpmailer 6 and send it out - // There is no way to retrieve the created mail e.g. for IMAP output - // This should be migrated to laminas-mail (used for imap) - // Phpmailer 6 can then be removed - $sysMailerSent = $sysMailer->composeAndSendEmail( - $from, - $from_name, - $recipients, - $betreff, - $body, - $files, - $ccRecipients, - $bccRecipients, - $sendmail_error - ); + if (!empty($recipients)) { + // This will build the mail with phpmailer 6 and send it out + // There is no way to retrieve the created mail e.g. for IMAP output + // This should be migrated to laminas-mail (used for imap) + // Phpmailer 6 can then be removed + $sysMailerSent = $sysMailer->composeAndSendEmail( + $from, + $from_name, + $recipients, + $betreff, + $body, + $files, + $ccRecipients, + $bccRecipients, + $sendmail_error + ); + } else { + $sendmail_error = "Kein Empfänger angegeben"; + } } if($sysMailerSent === false) { @@ -25742,11 +25746,12 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p $client->connect(); $client->appendMessage($imapCopyMessage, $account->getImapOutgoingFolder()); } catch (Exception $e) { - $this->app->erp->LogFile("Mailer Error: " . (string) $e); + $this->app->erp->LogFile("Mailer IMAP Error: " . (string) $e); if(isset($this->app->User) && $this->app->User && method_exists($this->app->User, 'GetID')) { $this->app->erp->InternesEvent($this->app->User->GetID(),"IMAP-Fehler","alert",1); } + $this->mail_error = "Mailer IMAP Error"; return 0; } }