Skip to content

Commit

Permalink
Merge branch 'set-connection-timeout-for-mail-transports' of https://…
Browse files Browse the repository at this point in the history
…github.com/RTLer/framework into RTLer-set-connection-timeout-for-mail-transports
  • Loading branch information
taylorotwell committed May 22, 2016
2 parents 3901470 + 4fdd0d2 commit 590d4a4
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Illuminate/Mail/TransportManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
}
Expand All @@ -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']
);
}

Expand All @@ -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']
);
}

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 590d4a4

Please sign in to comment.