8000 [Mailer] Improve error message when STARTTLS fails · symfony/symfony@9f7c485 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f7c485

Browse files
[Mailer] Improve error message when STARTTLS fails
1 parent 2468019 commit 9f7c485

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Symfony/Component/Mailer/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)
0