From 7fd94ecadce46ba20b25eb8b7c867d6f827214e6 Mon Sep 17 00:00:00 2001 From: tzmfreedom Date: Thu, 13 Jun 2019 22:12:44 +0900 Subject: [PATCH] add noOverrideParameters method not to override parameter --- src/Transport/Sendmail.php | 14 ++++++++++++++ test/Transport/SendmailTest.php | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/Transport/Sendmail.php b/src/Transport/Sendmail.php index 821c94e3..14afefef 100644 --- a/src/Transport/Sendmail.php +++ b/src/Transport/Sendmail.php @@ -42,6 +42,11 @@ class Sendmail implements TransportInterface */ protected $operatingSystem; + /** + * @var boolean + */ + protected $noOverrideParameters; + /** * Constructor. * @@ -53,6 +58,7 @@ public function __construct($parameters = null) $this->setParameters($parameters); } $this->callable = [$this, 'mailHandler']; + $this->noOverrideParameter = false; } /** @@ -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) { @@ -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? * diff --git a/test/Transport/SendmailTest.php b/test/Transport/SendmailTest.php index 9200863a..6d531fa4 100644 --- a/test/Transport/SendmailTest.php +++ b/test/Transport/SendmailTest.php @@ -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\'foo@example.com\''); + + $this->transport->send($message); + $this->assertEquals('-f\'foo@example.com\'', $this->additional_parameters); + } }