Merge pull request #17655 from ATM-Consulting/FIX_13.0_wrong_error_message_MAIN_DISABLE_ALL_MAILS

FIX 13.0 - wrong error message for mail sending failure
This commit is contained in:
Laurent Destailleur 2021-05-20 14:33:40 +02:00 committed by GitHub
commit 5eeb7d474c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -559,8 +559,10 @@ if (!$error && $massaction == 'confirm_presend')
{
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto);
$resaction .= '<br><div class="error">'.$mailfile->error.'</div>';
} else {
} elseif (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
$resaction .= '<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
} else {
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto) . '<br><div class="error">(unhandled error)</div>';
}
}
}

View File

@ -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 {