diff --git a/apps/settings/lib/Settings/Admin/Mail.php b/apps/settings/lib/Settings/Admin/Mail.php index 1cdb7315713c6..906fdf931eb62 100644 --- a/apps/settings/lib/Settings/Admin/Mail.php +++ b/apps/settings/lib/Settings/Admin/Mail.php @@ -28,6 +28,7 @@ namespace OCA\Settings\Settings\Admin; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IBinaryFinder; use OCP\IConfig; use OCP\IL10N; use OCP\Settings\IDelegatedSettings; diff --git a/apps/settings/tests/Settings/Admin/MailTest.php b/apps/settings/tests/Settings/Admin/MailTest.php index c3b08a9d50906..8fe5bda4d4f92 100644 --- a/apps/settings/tests/Settings/Admin/MailTest.php +++ b/apps/settings/tests/Settings/Admin/MailTest.php @@ -30,6 +30,7 @@ use OCA\Settings\Settings\Admin\Mail; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IBinaryFinder; use OCP\IConfig; use OCP\IL10N; use Test\TestCase; diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 2839c1c504e97..4cd523ba414b4 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -361,8 +361,10 @@ protected function getSendMailInstance(): SendmailTransport { break; default: $sendmail = \OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'); - if ($sendmail === null) { + if ($sendmail === false) { + // fallback (though not sure what good it'll do) $sendmail = '/usr/sbin/sendmail'; + $this->logger->debug('sendmail binary search failed, using fallback ' . $sendmail, ['app' => 'core']); } $binaryPath = $sendmail; break; @@ -373,6 +375,7 @@ protected function getSendMailInstance(): SendmailTransport { default => ' -bs', }; + $this->logger->debug('Using sendmail binary: ' . $binaryPath, ['app' => 'core']); return new SendmailTransport($binaryPath . $binaryParam, null, $this->logger); } } diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php index e3995fd17be12..5e8993f10ea90 100644 --- a/tests/lib/Mail/MailerTest.php +++ b/tests/lib/Mail/MailerTest.php @@ -16,6 +16,7 @@ use OC\Mail\Message; use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IBinaryFinder; use OCP\IConfig; use OCP\IL10N; use OCP\IURLGenerator; @@ -90,7 +91,7 @@ public function testGetSendmailInstanceSendMail($sendmailMode, $binaryParam) { ['mail_sendmailmode', 'smtp', $sendmailMode], ]); - $path = \OC_Helper::findBinaryPath('sendmail'); + $path = \OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'); if ($path === false) { $path = '/usr/sbin/sendmail'; }