fix(ticket): correct misleading MAIN_DISABLE_ALL_MAILS fallback error (#37994) (#37995)

sendTicketMessageByEmail() unconditionally told the admin

  'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'

whenever sendfile() returned false and $mailfile->error was empty.
sendfile() can also fail with an empty error on transient SMTP
errors or connection timeouts, so the message lied whenever
MAIN_DISABLE_ALL_MAILS was not actually configured — confusing
admins about why delivery failed.

Branch on getDolGlobalString('MAIN_DISABLE_ALL_MAILS'):
  * true  -> keep the disabled-feature notice
  * false -> fall through to ErrorFailedToSendMail and a syslog
             entry noting sendfile() returned false with no
             specific error.

Fixes #37994

Signed-off-by: SAY-5 <say.apm35@gmail.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Sai Asish Y 2026-04-26 18:11:09 -07:00 committed by GitHub
parent 72306e9e8f
commit 2003f4bf95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3308,12 +3308,12 @@ class Ticket extends CommonObject
$langs->load("other");
if ($mailfile->error) {
setEventMessages($langs->trans('ErrorFailedToSendMail', $from, $receiverstring), null, 'errors');
dol_syslog($langs->trans('ErrorFailedToSendMail', $from, $receiverstring).' : '.$mailfile->error);
dol_syslog('ErrorFailedToSendMail from='.$from.' to='.$receiverstring.' : '.$mailfile->error);
} elseif (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'errors');
} else {
setEventMessages($langs->trans('ErrorFailedToSendMail', $from, $receiverstring), null, 'errors');
dol_syslog('ErrorFailedToSendMail (no error details) from='.$from.' to='.$receiverstring, LOG_WARNING);
dol_syslog('ErrorFailedToSendMail from='.$from.' to='.$receiverstring.' : (no error details)', LOG_WARNING);
}
}
}