]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fallback to default path is sendmail can't be found 11404/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Fri, 2 Nov 2018 13:03:11 +0000 (14:03 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 2 Nov 2018 13:03:11 +0000 (14:03 +0100)
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>
lib/private/Mail/Mailer.php
tests/lib/Mail/MailerTest.php

index 79208f9a69517f6c60b7a635add3939b38965db4..df23b66936577325ac8cc6efbe4eadb6b5673812 100644 (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;
                }
 
index d724cd630d32f455a4c431914f9c2d8857ea0f3b..ddae38ff54dbf7c13ef559a555d568ecb790b327 100644 (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() {