Fallback to default path is sendmail can't be found

If the sendmail binary can't be found at all we fallback to the default
path.
It most likely is not there but then at least a proper error message
pops up.

Updated the tests to also properly pass.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-11-02 14:03:11 +01:00
parent 7078a0e53e
commit 054056a8df
No known key found for this signature in database
GPG Key ID: F941078878347C0C
2 changed files with 12 additions and 2 deletions

View File

@ -274,7 +274,11 @@ class Mailer implements IMailer {
$binaryPath = '/var/qmail/bin/sendmail';
break;
default:
$binaryPath = \OC_Helper::findBinaryPath('sendmail');
$sendmail = \OC_Helper::findBinaryPath('sendmail');
if ($sendmail === null) {
$sendmail = '/usr/sbin/sendmail';
}
$binaryPath = $sendmail;
break;
}

View File

@ -55,7 +55,13 @@ class MailerTest extends TestCase {
->with('mail_smtpmode', 'smtp')
->will($this->returnValue('sendmail'));
$this->assertEquals(new \Swift_SendmailTransport('/usr/sbin/sendmail -bs'), self::invokePrivate($this->mailer, 'getSendMailInstance'));
$path = \OC_Helper::findBinaryPath('sendmail');
if ($path === null) {
$path = '/usr/sbin/sendmail';
}
$expected = new \Swift_SendmailTransport($path . ' -bs');
$this->assertEquals($expected, self::invokePrivate($this->mailer, 'getSendMailInstance'));
}
public function testGetSendMailInstanceSendMailQmail() {