Skip to content

Commit d998397

Browse files
zabousdg
authored andcommitted
SendmailMailer: the use of -f option in the mail command can be disabled (#98)
1 parent 05fec09 commit d998397

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Mail/SendmailMailer.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class SendmailMailer implements Mailer
1919
{
2020
public string $commandArgs = '';
2121
private ?Signer $signer = null;
22+
private bool $envelopeSender = true;
2223

2324

2425
public function setSigner(Signer $signer): static
@@ -28,6 +29,16 @@ public function setSigner(Signer $signer): static
2829
}
2930

3031

32+
/**
33+
* Sets whether to use the envelope sender (-f option) in the mail command.
34+
*/
35+
public function setEnvelopeSender(bool $state = true): static
36+
{
37+
$this->envelopeSender = $state;
38+
return $this;
39+
}
40+
41+
3142
/**
3243
* Sends email.
3344
* @throws SendException
@@ -48,7 +59,7 @@ public function send(Message $mail): void
4859
$parts = explode(Message::EOL . Message::EOL, $data, 2);
4960

5061
$cmd = $this->commandArgs;
51-
if ($from = $mail->getFrom()) {
62+
if ($this->envelopeSender && ($from = $mail->getFrom())) {
5263
$cmd .= ' -f' . key($from);
5364
}
5465

0 commit comments

Comments
 (0)