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

Commit 7fd94ec

Browse files
committed
add noOverrideParameters method not to override parameter
1 parent ece418b commit 7fd94ec

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/Transport/Sendmail.php

+14
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class Sendmail implements TransportInterface
4242
*/
4343
protected $operatingSystem;
4444

45+
/**
46+
* @var boolean
47+
*/
48+
protected $noOverrideParameters;
49+
4550
/**
4651
* Constructor.
4752
*
@@ -53,6 +58,7 @@ public function __construct($parameters = null)
5358
$this->setParameters($parameters);
5459
}
5560
$this->callable = [$this, 'mailHandler'];
61+
$this->noOverrideParameter = false;
5662
}
5763

5864
/**
@@ -259,6 +265,9 @@ protected function prepareParameters(Mail\Message $message)
259265
}
260266

261267
$parameters = (string) $this->parameters;
268+
if ($this->noOverrideParameters) {
269+
return $parameters;
270+
}
262271

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

334+
public function noOverrideParameters()
335+
{
336+
$this->noOverrideParameters = true;
337+
}
338+
325339
/**
326340
* Is this a windows OS?
327341
*

test/Transport/SendmailTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,18 @@ public function testDoNotAllowMessageWithoutToAndCcAndBccHeaders()
252252
$this->expectException(RuntimeException::class);
253253
$this->transport->send($message);
254254
}
255+
256+
public function testNotOverrideParameters()
257+
{
258+
if ($this->operating_system == 'WIN') {
259+
$this->markTestSkipped('This test is *nix-specific');
260+
}
261+
262+
$message = $this->getMessage();
263+
$this->transport->noOverrideParameters();
264+
$this->transport->setParameters('-f\'[email protected]\'');
265+
266+
$this->transport->send($message);
267+
$this->assertEquals('-f\'[email protected]\'', $this->additional_parameters);
268+
}
255269
}

0 commit comments

Comments
 (0)