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

When set -f option, no set -f option automatically #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}