Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Backport Mailgun endpoint fix #26592

Merged
merged 1 commit into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/Illuminate/Mail/Transport/MailgunTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ class MailgunTransport extends Transport
*
* @var string
*/
protected $url;
protected $endpoint;

/**
* Create a new Mailgun transport instance.
*
* @param \GuzzleHttp\ClientInterface $client
* @param string $key
* @param string $domain
* @param string|null $endpoint
* @return void
*/
public function __construct(ClientInterface $client, $key, $domain)
public function __construct(ClientInterface $client, $key, $domain, $endpoint = null)
{
$this->key = $key;
$this->client = $client;
$this->endpoint = $endpoint ?? 'api.mailgun.net';

$this->setDomain($domain);
}

Expand All @@ -61,7 +64,11 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul

$message->setBcc([]);

$this->client->post($this->url, $this->payload($message, $to));
$this->client->request(
'POST',
"https://{$this->endpoint}/v3/{$this->domain}/messages.mime",
$this->payload($message, $to)
);

$this->sendPerformed($message);

Expand Down Expand Up @@ -161,8 +168,6 @@ public function getDomain()
*/
public function setDomain($domain)
{
$this->url = 'https://api.mailgun.net/v3/'.$domain.'/messages.mime';

return $this->domain = $domain;
}
}
4 changes: 3 additions & 1 deletion src/Illuminate/Mail/TransportManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ protected function createMailgunDriver()

return new MailgunTransport(
$this->guzzle($config),
$config['secret'], $config['domain']
$config['secret'],
$config['domain'],
$config['endpoint'] ?? null
);
}

Expand Down