From 6cccd77508d2c41c5860bfa9098a1e7bd4b090da Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Tue, 18 May 2021 17:57:23 +0200 Subject: [PATCH] FIX 13.0 - error message says MAIN_DISABLE_ALL_MAILS is set when it isn't + unhandled swiftmailer error (failed recipients due to RFC 2822 non-compliance) --- htdocs/core/actions_massactions.inc.php | 4 +++- htdocs/core/class/CMailFile.class.php | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 6b6d5854a1d..99f1271ff0b 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -559,8 +559,10 @@ if (!$error && $massaction == 'confirm_presend') { $resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); $resaction .= '
'.$mailfile->error.'
'; - } else { + } elseif (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { $resaction .= '
No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
'; + } else { + $resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto) . '
(unhandled error)
'; } } } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c942127aab3..67c3387fbc8 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -894,7 +894,7 @@ class CMailFile } // send mail try { - $result = $this->mailer->send($this->message); + $result = $this->mailer->send($this->message, $failedRecipients); } catch (Exception $e) { $this->error = $e->getMessage(); } @@ -902,6 +902,9 @@ class CMailFile $res = true; if (!empty($this->error) || !$result) { + if (!empty($failedRecipients)) { + $this->error = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".'; + } dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); $res = false; } else {