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

Commit

Permalink
add noOverrideParameters method not to override parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
tzmfreedom committed Jun 13, 2019
1 parent ece418b commit 7fd94ec
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Transport/Sendmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class Sendmail implements TransportInterface
*/
protected $operatingSystem;

/**
* @var boolean
*/
protected $noOverrideParameters;

/**
* Constructor.
*
Expand All @@ -53,6 +58,7 @@ public function __construct($parameters = null)
$this->setParameters($parameters);
}
$this->callable = [$this, 'mailHandler'];
$this->noOverrideParameter = false;
}

/**
Expand Down Expand Up @@ -259,6 +265,9 @@ protected function prepareParameters(Mail\Message $message)
}

$parameters = (string) $this->parameters;
if ($this->noOverrideParameters) {
return $parameters;
}

$sender = $message->getSender();
if ($sender instanceof AddressInterface) {
Expand Down Expand Up @@ -322,6 +331,11 @@ public function handleMailErrors($errno, $errstr, $errfile = null, $errline = nu
return true;
}

public function noOverrideParameters()
{
$this->noOverrideParameters = true;
}

/**
* Is this a windows OS?
*
Expand Down
14 changes: 14 additions & 0 deletions test/Transport/SendmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,18 @@ public function testDoNotAllowMessageWithoutToAndCcAndBccHeaders()
$this->expectException(RuntimeException::class);
$this->transport->send($message);
}

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

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

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

0 comments on commit 7fd94ec

Please sign in to comment.