diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index 7494f5a3668..3749b403469 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -427,9 +427,14 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
} else {
$langs->load("other");
$mesg = '
';
- if ($mailfile->error) {
+ if (!empty($mailfile->error) || !empty($mailfile->errors)) {
$mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
- $mesg .= '
'.$mailfile->error;
+ if (!empty($mailfile->error)) {
+ $mesg .= '
'.$mailfile->error;
+ }
+ if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
+ $mesg .= '
'.implode('
', $mailfile->errors);
+ }
} else {
$mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index b991b4542f9..f299ecf9a88 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -1008,16 +1008,16 @@ class CMailFile
try {
$result = $this->mailer->send($this->message, $failedRecipients);
} catch (Exception $e) {
- $this->error = $e->getMessage();
+ $this->errors[] = $e->getMessage();
}
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->dump_mail();
}
$res = true;
- if (!empty($this->error) || !$result) {
+ if (!empty($this->error) || !empty($this->errors) || !$result) {
if (!empty($failedRecipients)) {
- $this->error = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
+ $this->errors[] = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
}
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
$res = false;