From 4237f902a3aa3e1524a98f9d371955a14331e89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Aug 2022 10:09:52 +0200 Subject: [PATCH] add oauth2 for swiftmailer --- htdocs/core/actions_sendmails.inc.php | 9 +++++++-- htdocs/core/class/CMailFile.class.php | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) 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;