Skip to content

Commit

Permalink
SendmailMailer: the use of -f option in the mail command can be disab…
Browse files Browse the repository at this point in the history
…led (#98)
  • Loading branch information
zabous authored and dg committed Oct 4, 2024
1 parent 7d582f1 commit cce2055
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Mail/SendmailMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SendmailMailer implements Mailer
{
public string $commandArgs = '';
private ?Signer $signer = null;
private bool $envelopeSender = true;


public function setSigner(Signer $signer): static
Expand All @@ -28,6 +29,16 @@ public function setSigner(Signer $signer): static
}


/**
* Sets whether to use the envelope sender (-f option) in the mail command.
*/
public function setEnvelopeSender(bool $state = true): static
{
$this->envelopeSender = $state;
return $this;
}


/**
* Sends email.
* @throws SendException
Expand All @@ -48,7 +59,7 @@ public function send(Message $mail): void
$parts = explode(Message::EOL . Message::EOL, $data, 2);

$cmd = $this->commandArgs;
if ($from = $mail->getFrom()) {
if ($this->envelopeSender && ($from = $mail->getFrom())) {
$cmd .= ' -f' . key($from);
}

Expand Down

0 comments on commit cce2055

Please sign in to comment.