diff --git a/src/Illuminate/Mail/Transport/MailgunTransport.php b/src/Illuminate/Mail/Transport/MailgunTransport.php index 678a4d5eb9c0..0a03356c129e 100644 --- a/src/Illuminate/Mail/Transport/MailgunTransport.php +++ b/src/Illuminate/Mail/Transport/MailgunTransport.php @@ -75,7 +75,6 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) 'message' => new PostFile('message', $message->toString()), ]; } - $options['connect_timeout'] = 60; return $this->client->post($this->url, $options); } diff --git a/src/Illuminate/Mail/Transport/MandrillTransport.php b/src/Illuminate/Mail/Transport/MandrillTransport.php index b5a5e485c85c..32f4e107db41 100644 --- a/src/Illuminate/Mail/Transport/MandrillTransport.php +++ b/src/Illuminate/Mail/Transport/MandrillTransport.php @@ -53,7 +53,6 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) } else { $options = ['body' => $data]; } - $options['connect_timeout'] = 60; return $this->client->post('https://mandrillapp.com/api/1.0/messages/send-raw.json', $options); } diff --git a/src/Illuminate/Mail/Transport/SparkPostTransport.php b/src/Illuminate/Mail/Transport/SparkPostTransport.php index 305e06d8e075..e4479d0baa29 100644 --- a/src/Illuminate/Mail/Transport/SparkPostTransport.php +++ b/src/Illuminate/Mail/Transport/SparkPostTransport.php @@ -47,7 +47,6 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $message->setBcc([]); $options = [ - 'connect_timeout' => 60, 'headers' => [ 'Authorization' => $this->key, ], diff --git a/src/Illuminate/Mail/TransportManager.php b/src/Illuminate/Mail/TransportManager.php index 2c1dae1ede91..9e83a1ac88a2 100644 --- a/src/Illuminate/Mail/TransportManager.php +++ b/src/Illuminate/Mail/TransportManager.php @@ -101,7 +101,7 @@ protected function createMailgunDriver() $config = $this->app['config']->get('services.mailgun', []); return new MailgunTransport( - new HttpClient(Arr::get($config, 'guzzle', [])), + $this->getHttpClient($config), $config['secret'], $config['domain'] ); } @@ -116,7 +116,7 @@ protected function createMandrillDriver() $config = $this->app['config']->get('services.mandrill', []); return new MandrillTransport( - new HttpClient(Arr::get($config, 'guzzle', [])), $config['secret'] + $this->getHttpClient($config), $config['secret'] ); } @@ -130,7 +130,7 @@ protected function createSparkPostDriver() $config = $this->app['config']->get('services.sparkpost', []); return new SparkPostTransport( - new HttpClient(Arr::get($config, 'guzzle', [])), $config['secret'] + $this->getHttpClient($config), $config['secret'] ); } @@ -164,4 +164,19 @@ public function setDefaultDriver($name) { $this->app['config']['mail.driver'] = $name; } + + /** + * get configured http client + * @param $config + * @return HttpClient + */ + protected function getHttpClient($config) + { + $guzzleConfig = Arr::get($config, 'guzzle', []); + + // add default config for timeout + $guzzleConfig = Arr::add($guzzleConfig, 'connect_timeout', 60); + + return new HttpClient($guzzleConfig); + } }