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 {