Skip to content

Commit

Permalink
Fixes laminas#17 : Fixes when set -f option, no set -f option automat…
Browse files Browse the repository at this point in the history
…ically

Signed-off-by: Abdul Malik Ikhsan <[email protected]>
  • Loading branch information
samsonasik authored and weierophinney committed Aug 6, 2020
1 parent 3e75f3c commit fb03157
Show file tree
Hide file tree
Showing 2 changed files with 29 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 @@ -255,6 +255,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
26 changes: 26 additions & 0 deletions test/Transport/SendmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,30 @@ public function testHeadersToAndSubjectAreNotDuplicated()
$this->assertNotRegExp('/^To: matthew\@example\.org$/m', $this->additional_headers);
$this->assertNotRegExp('/^Subject: Greetings and Salutations!$/m', $this->additional_headers);
}

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 fb03157

Please sign in to comment.