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

Commit 92fe2c9

Browse files
committed
only when -f option is set, set -f option automatically
1 parent ece418b commit 92fe2c9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/Transport/Sendmail.php

+3
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ protected function prepareParameters(Mail\Message $message)
259259
}
260260

261261
$parameters = (string) $this->parameters;
262+
if (preg_match('/^\-f.+$/', $parameters) || strpos($parameters, ' -f') !== false) {
263+
return $parameters;
264+
}
262265

263266
$sender = $message->getSender();
264267
if ($sender instanceof AddressInterface) {

test/Transport/SendmailTest.php

+27
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class SendmailTest extends TestCase
2727
public $message;
2828
public $additional_headers;
2929
public $additional_parameters;
30+
public $operating_system;
3031

3132
public function setUp()
3233
{
@@ -252,4 +253,30 @@ public function testDoNotAllowMessageWithoutToAndCcAndBccHeaders()
252253
$this->expectException(RuntimeException::class);
253254
$this->transport->send($message);
254255
}
256+
257+
public function testNotSetOptionAutomaticallyOnLeadingF()
258+
{
259+
if ($this->operating_system == 'WIN') {
260+
$this->markTestSkipped('This test is *nix-specific');
261+
}
262+
263+
$message = $this->getMessage();
264+
$this->transport->setParameters('-f\'[email protected]\'');
265+
266+
$this->transport->send($message);
267+
$this->assertEquals('-f\'[email protected]\'', $this->additional_parameters);
268+
}
269+
270+
public function testNotSetOptionAutomaticallyOnMiddleF()
271+
{
272+
if ($this->operating_system == 'WIN') {
273+
$this->markTestSkipped('This test is *nix-specific');
274+
}
275+
276+
$message = $this->getMessage();
277+
$this->transport->setParameters('-bs -f\'[email protected]\'');
278+
279+
$this->transport->send($message);
280+
$this->assertEquals('-bs -f\'[email protected]\'', $this->additional_parameters);
281+
}
255282
}

0 commit comments

Comments
 (0)