Skip to content

Commit

Permalink
[Mailer] Improve error message when STARTTLS fails
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Sep 28, 2021
1 parent 2468019 commit 9f7c485
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,14 @@ public function initialize(): void

public function startTLS(): bool
{
return (bool) stream_socket_enable_crypto($this->stream, true);
set_error_handler(function ($type, $msg) {
throw new TransportException('Unable to connect with STARTTLS: '.$msg);
});
try {
return stream_socket_enable_crypto($this->stream, true);
} finally {
restore_error_handler();
}
}

public function terminate(): void
Expand Down

0 comments on commit 9f7c485

Please sign in to comment.