Skip to content

Commit

Permalink
Merge pull request #11404 from flokli/sendmail-path
Browse files Browse the repository at this point in the history
Mailer: discover sendmail path instead of hardcoding it to /usr/sbin/sendmail
  • Loading branch information
rullzer authored Nov 2, 2018
2 parents 30a1237 + 054056a commit 4ba709b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/private/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ protected function getSendMailInstance(): \Swift_SendmailTransport {
$binaryPath = '/var/qmail/bin/sendmail';
break;
default:
$binaryPath = '/usr/sbin/sendmail';
$sendmail = \OC_Helper::findBinaryPath('sendmail');
if ($sendmail === null) {
$sendmail = '/usr/sbin/sendmail';
}
$binaryPath = $sendmail;
break;
}

Expand Down
8 changes: 7 additions & 1 deletion tests/lib/Mail/MailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ public function testGetSendMailInstanceSendMail() {
->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() {
Expand Down

0 comments on commit 4ba709b

Please sign in to comment.