Skip to content

Commit fb03157

Browse files
samsonasikweierophinney
authored andcommitted
Fixes laminas#17 : Fixes when set -f option, no set -f option automatically
Signed-off-by: Abdul Malik Ikhsan <[email protected]>
1 parent 3e75f3c commit fb03157

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/Transport/Sendmail.php

+3
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ protected function prepareParameters(Mail\Message $message)
255255
}
256256

257257
$parameters = (string) $this->parameters;
258+
if (preg_match('/^\-f.+$/', $parameters) || strpos($parameters, ' -f') !== false) {
259+
return $parameters;
260+
}
258261

259262
$sender = $message->getSender();
260263
if ($sender instanceof AddressInterface) {

test/Transport/SendmailTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,30 @@ public function testHeadersToAndSubjectAreNotDuplicated()
282282
$this->assertNotRegExp('/^To: matthew\@example\.org$/m', $this->additional_headers);
283283
$this->assertNotRegExp('/^Subject: Greetings and Salutations!$/m', $this->additional_headers);
284284
}
285+
286+
public function testNotSetOptionAutomaticallyOnLeadingF()
287+
{
288+
if ($this->operating_system == 'WIN') {
289+
$this->markTestSkipped('This test is *nix-specific');
290+
}
291+
292+
$message = $this->getMessage();
293+
$this->transport->setParameters('-f\'[email protected]\'');
294+
295+
$this->transport->send($message);
296+
$this->assertEquals('-f\'[email protected]\'', $this->additional_parameters);
297+
}
298+
299+
public function testNotSetOptionAutomaticallyOnMiddleF()
300+
{
301+
if ($this->operating_system == 'WIN') {
302+
$this->markTestSkipped('This test is *nix-specific');
303+
}
304+
305+
$message = $this->getMessage();
306+
$this->transport->setParameters('-bs -f\'[email protected]\'');
307+
308+
$this->transport->send($message);
309+
$this->assertEquals('-bs -f\'[email protected]\'', $this->additional_parameters);
310+
}
285311
}

0 commit comments

Comments
 (0)