mirror of
https://github.com/nextcloud/server.git
synced 2026-04-28 01:28:08 -04:00
Merge pull request #46480 from nextcloud/fix/mailer-binaryfinder-fallback
fix(Mailer): Fix sendmail binary fallback
This commit is contained in:
commit
ede0c26b78
4 changed files with 10 additions and 4 deletions
|
|
@ -6,6 +6,7 @@
|
|||
namespace OCA\Settings\Settings\Admin;
|
||||
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IBinaryFinder;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\Settings\IDelegatedSettings;
|
||||
|
|
@ -32,7 +33,7 @@ class Mail implements IDelegatedSettings {
|
|||
public function getForm() {
|
||||
$parameters = [
|
||||
// Mail
|
||||
'sendmail_is_available' => (bool)\OC_Helper::findBinaryPath('sendmail'),
|
||||
'sendmail_is_available' => (bool)\OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'),
|
||||
'mail_domain' => $this->config->getSystemValue('mail_domain', ''),
|
||||
'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''),
|
||||
'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''),
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace OCA\Settings\Tests\Settings\Admin;
|
|||
|
||||
use OCA\Settings\Settings\Admin\Mail;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IBinaryFinder;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use Test\TestCase;
|
||||
|
|
@ -51,7 +52,7 @@ class MailTest extends TestCase {
|
|||
'settings',
|
||||
'settings/admin/additional-mail',
|
||||
[
|
||||
'sendmail_is_available' => (bool)\OC_Helper::findBinaryPath('sendmail'),
|
||||
'sendmail_is_available' => (bool)\OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'),
|
||||
'mail_domain' => 'mx.nextcloud.com',
|
||||
'mail_from_address' => 'no-reply@nextcloud.com',
|
||||
'mail_smtpmode' => 'smtp',
|
||||
|
|
|
|||
|
|
@ -334,8 +334,10 @@ class Mailer implements IMailer {
|
|||
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;
|
||||
|
|
@ -346,6 +348,7 @@ class Mailer implements IMailer {
|
|||
default => ' -bs',
|
||||
};
|
||||
|
||||
$this->logger->debug('Using sendmail binary: ' . $binaryPath, ['app' => 'core']);
|
||||
return new SendmailTransport($binaryPath . $binaryParam, null, $this->logger);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use OC\Mail\Mailer;
|
|||
use OC\Mail\Message;
|
||||
use OCP\Defaults;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IBinaryFinder;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
|
|
@ -86,7 +87,7 @@ class MailerTest extends TestCase {
|
|||
['mail_sendmailmode', 'smtp', $sendmailMode],
|
||||
]);
|
||||
|
||||
$path = \OC_Helper::findBinaryPath('sendmail');
|
||||
$path = \OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail');
|
||||
if ($path === false) {
|
||||
$path = '/usr/sbin/sendmail';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue