8000 minor #43238 [Mailer] Improve error message when STARTTLS fails (nico… · symfony/symfony@498284e · GitHub
[go: up one dir, main page]

Skip to content

Commit 498284e

Browse files
committed
minor #43238 [Mailer] Improve error message when STARTTLS fails (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [Mailer] Improve error message when STARTTLS fails | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- 9f7c485 [Mailer] Improve error message when STARTTLS fails
2 parents c6a0be2 + 9f7c485 commit 498284e

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