Skip to content

Commit

Permalink
[Mailer] Fix sendmail transport not handling failure
Browse files Browse the repository at this point in the history
  • Loading branch information
aboks committed Mar 11, 2024
1 parent 359d59e commit 227d166
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ abstract class AbstractStream
protected $stream;
protected $in;
protected $out;
protected $err;

private $debug = '';

Expand Down Expand Up @@ -65,7 +66,7 @@ abstract public function initialize(): void;

public function terminate(): void
{
$this->stream = $this->out = $this->in = null;
$this->stream = $this->err = $this->out = $this->in = null;
}

public function readLine(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,21 @@ public function initialize(): void
}
$this->in = &$pipes[0];
$this->out = &$pipes[1];
$this->err = &$pipes[2];
}

public function terminate(): void
{
if (null !== $this->stream) {
fclose($this->in);
$out = stream_get_contents($this->out);
fclose($this->out);
proc_close($this->stream);
$err = stream_get_contents($this->err);
fclose($this->err);
$exitCode = proc_close($this->stream);
if (0 !== $exitCode) {
throw new TransportException('Process failed with exit code '.$exitCode.': '.$out.$err);
}
}

parent::terminate();
Expand Down

0 comments on commit 227d166

Please sign in to comment.