Skip to content

Commit

Permalink
SendmailMailer: fixed $commandArgs handling after 0e236e4 [Closes #93]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 23, 2023
1 parent 90b6737 commit 6a2ee30
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Mail/SendmailMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class SendmailMailer implements Mailer
{
public ?string $commandArgs = null;
public string $commandArgs = '';
private ?Signer $signer = null;


Expand Down Expand Up @@ -47,21 +47,19 @@ public function send(Message $mail): void
: $tmp->generateMessage();
$parts = explode(Message::EOL . Message::EOL, $data, 2);

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

$args = [
(string) $mail->getEncodedHeader('To'),
(string) $mail->getEncodedHeader('Subject'),
$parts[1],
$parts[0],
$cmd,
];

if ($from = $mail->getFrom()) {
$args[] = '-f' . key($from);
}

if ($this->commandArgs) {
$args[] = $this->commandArgs;
}

$res = Nette\Utils\Callback::invokeSafe('mail', $args, function (string $message) use (&$info): void {
$info = ": $message";
});
Expand Down

0 comments on commit 6a2ee30

Please sign in to comment.