Skip to content

Commit 01d8181

Browse files
[Mailer] Improve error message when STARTTLS fails
1 parent a455d59 commit 01d8181

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Transport/Smtp/Stream/SocketStream.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,14 @@ public function initialize(): void
167167

168168
public function startTLS(): bool
169169
{
170-
return (bool) stream_socket_enable_crypto($this->stream, true);
170+
set_error_handler(function ($type, $msg) {
171+
throw new TransportException('Unable to connect with STARTTLS: '.$msg);
172+
});
173+
try {
174+
return stream_socket_enable_crypto($this->stream, true);
175+
} finally {
176+
restore_error_handler();
177+
}
171178
}
172179

173180
public function terminate(): void

0 commit comments

Comments
 (0)