Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f0fbdee

Browse filesBrowse files
committed
feature #35194 [Mailer] read default timeout from ini configurations (azjezz)
This PR was merged into the 5.1-dev branch. Discussion ---------- [Mailer] read default timeout from ini configurations | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #35138 | License | MIT | Doc PR | n/a ```env MAILER_DSN=mandrill+https://foo@default?timeout=30 ``` Commits ------- dafb057 [Mailer] read default timeout from ini configurations
2 parents 3945a5c + dafb057 commit f0fbdee
Copy full SHA for f0fbdee

File tree

1 file changed

+5
-4
lines changed
Filter options

1 file changed

+5
-4
lines changed

‎src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class SocketStream extends AbstractStream
2626
private $url;
2727
private $host = 'localhost';
2828
private $port = 465;
29-
private $timeout = 5;
29+
private $timeout;
3030
private $tls = true;
3131
private $sourceIp;
3232
private $streamContextOptions = [];
@@ -40,7 +40,7 @@ public function setTimeout(float $timeout): self
4040

4141
public function getTimeout(): float
4242
{
43-
return $this->timeout;
43+
return $this->timeout ?? (float) ini_get('default_socket_timeout');
4444
}
4545

4646
/**
@@ -134,17 +134,18 @@ public function initialize(): void
134134
$options['ssl']['crypto_method'] = $options['ssl']['crypto_method'] ?? STREAM_CRYPTO_METHOD_TLS_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
135135
$streamContext = stream_context_create($options);
136136

137+
$timeout = $this->getTimeout();
137138
set_error_handler(function ($type, $msg) {
138139
throw new TransportException(sprintf('Connection could not be established with host "%s": %s.', $this->url, $msg));
139140
});
140141
try {
141-
$this->stream = stream_socket_client($this->url, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $streamContext);
142+
$this->stream = stream_socket_client($this->url, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
142143
} finally {
143144
restore_error_handler();
144145
}
145146

146147
stream_set_blocking($this->stream, true);
147-
stream_set_timeout($this->stream, $this->timeout);
148+
stream_set_timeout($this->stream, $timeout);
148149
$this->in = &$this->stream;
149150
$this->out = &$this->stream;
150151
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.