diff --git a/src/Transport/Sendmail.php b/src/Transport/Sendmail.php index 98ee2142..1929e82d 100644 --- a/src/Transport/Sendmail.php +++ b/src/Transport/Sendmail.php @@ -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) { diff --git a/test/Transport/SendmailTest.php b/test/Transport/SendmailTest.php index 111f8f3b..525a0435 100644 --- a/test/Transport/SendmailTest.php +++ b/test/Transport/SendmailTest.php @@ -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\'foo@example.com\''); + + $this->transport->send($message); + $this->assertEquals('-f\'foo@example.com\'', $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\'foo@example.com\''); + + $this->transport->send($message); + $this->assertEquals('-bs -f\'foo@example.com\'', $this->additional_parameters); + } }