Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
only when -f option is set, set -f option automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
tzmfreedom committed Jun 19, 2019
1 parent ece418b commit 92fe2c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Transport/Sendmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ protected function prepareParameters(Mail\Message $message)
}

$parameters = (string) $this->parameters;
if (preg_match('/^\-f.+$/', $parameters) || strpos($parameters, ' -f') !== false) {
return $parameters;
}

$sender = $message->getSender();
if ($sender instanceof AddressInterface) {
Expand Down
27 changes: 27 additions & 0 deletions test/Transport/SendmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SendmailTest extends TestCase
public $message;
public $additional_headers;
public $additional_parameters;
public $operating_system;

public function setUp()
{
Expand Down Expand Up @@ -252,4 +253,30 @@ public function testDoNotAllowMessageWithoutToAndCcAndBccHeaders()
$this->expectException(RuntimeException::class);
$this->transport->send($message);
}

public function testNotSetOptionAutomaticallyOnLeadingF()
{
if ($this->operating_system == 'WIN') {
$this->markTestSkipped('This test is *nix-specific');
}

$message = $this->getMessage();
$this->transport->setParameters('-f\'[email protected]\'');

$this->transport->send($message);
$this->assertEquals('-f\'[email protected]\'', $this->additional_parameters);
}

public function testNotSetOptionAutomaticallyOnMiddleF()
{
if ($this->operating_system == 'WIN') {
$this->markTestSkipped('This test is *nix-specific');
}

$message = $this->getMessage();
$this->transport->setParameters('-bs -f\'[email protected]\'');

$this->transport->send($message);
$this->assertEquals('-bs -f\'[email protected]\'', $this->additional_parameters);
}
}

0 comments on commit 92fe2c9

Please sign in to comment.