Skip to content

Commit

Permalink
SendmailMailer: setting envelope addres can be disabled (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
zabous authored Oct 4, 2024
1 parent 7d582f1 commit 17504e3
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,8 @@ class SendmailMailer implements Mailer
{
public string $commandArgs = '';
private ?Signer $signer = null;
// Setting an envelope address using command arg (-f $from) is allowed by default
private bool envelopeFrom = true;

Check failure on line 23 in src/Mail/SendmailMailer.php

View workflow job for this annotation

GitHub Actions / PHPStan

Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 23


public function setSigner(Signer $signer): static
Expand All @@ -27,6 +29,15 @@ public function setSigner(Signer $signer): static
return $this;
}

/**
* Enable/disable setting an envelope address using command arg (-f $from)
*/
public function setEnvelopeFrom(bool $envelopeFrom): static
{
$this->evelopeFrom = $envelopeFrom;
return $this;
}


/**
* Sends email.
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->evelopeFrom) && ($from = $mail->getFrom())) {
$cmd .= ' -f' . key($from);
}

Expand Down

0 comments on commit 17504e3

Please sign in to comment.