Skip to content

Commit 6616da5

Browse files
committed
Merge branch '4.4'
* 4.4: [Mailer] fixed previous merge
2 parents 7e157dd + 5ac7977 commit 6616da5

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

Exception/UnsupportedHostException.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ class UnsupportedHostException extends LogicException
4848

4949
public function __construct(Dsn $dsn)
5050
{
51-
$host = $dsn->getHost();
52-
$package = self::HOST_TO_PACKAGE_MAP[$host] ?? null;
51+
$provider = $dsn->getScheme();
52+
if (false !== $pos = strpos($provider, '+')) {
53+
$provider = substr($provider, 0, $pos);
54+
}
55+
$package = self::HOST_TO_PACKAGE_MAP[$provider] ?? null;
5356
if ($package && !class_exists($package['class'])) {
5457
parent::__construct(sprintf('Unable to send emails via "%s" as the bridge is not installed. Try running "composer require %s".', $host, $package['package']));
5558

5659
return;
5760
}
5861

59-
parent::__construct(sprintf('The "%s" mailer is not supported.', $host));
62+
parent::__construct(sprintf('The "%s" scheme is not supported.', $dsn->getScheme()));
6063
}
6164
}

Mailgun/Transport/MailgunApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function doSendApi(Email $email, SmtpEnvelope $envelope): ResponseInte
5454
$headers[] = $header->toString();
5555
}
5656

57-
$endpoint = str_replace('%domain%', urlencode($this->domain), $this->getEndpoint()).'/v3/%domain%/messages';
57+
$endpoint = sprintf('%s/v3/%s/messages', $this->getEndpoint(), urlencode($this->domain));
5858
$response = $this->client->request('POST', 'https://'.$endpoint, [
5959
'auth_basic' => 'api:'.$this->key,
6060
'headers' => $headers,

Mailgun/Transport/MailgunHttpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
5757
$headers[] = $header->toString();
5858
}
5959

60-
$endpoint = str_replace('%domain%', urlencode($this->domain), $this->getEndpoint()).'/v3/%domain%/messages.mime';
60+
$endpoint = sprintf('%s/v3/%s/messages.mime', $this->getEndpoint(), urlencode($this->domain));
6161
$response = $this->client->request('POST', 'https://'.$endpoint, [
6262
'auth_basic' => 'api:'.$this->key,
6363
'headers' => $headers,

MailgunApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function doSendApi(Email $email, SmtpEnvelope $envelope): ResponseInte
5454
$headers[] = $header->toString();
5555
}
5656

57-
$endpoint = str_replace('%domain%', urlencode($this->domain), $this->getEndpoint()).'/v3/%domain%/messages';
57+
$endpoint = sprintf('%s/v3/%s/messages', $this->getEndpoint(), urlencode($this->domain));
5858
$response = $this->client->request('POST', 'https://'.$endpoint, [
5959
'auth_basic' => 'api:'.$this->key,
6060
'headers' => $headers,

MailgunHttpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
5757
$headers[] = $header->toString();
5858
}
5959

60-
$endpoint = str_replace('%domain%', urlencode($this->domain), $this->getEndpoint()).'/v3/%domain%/messages.mime';
60+
$endpoint = sprintf('%s/v3/%s/messages.mime', $this->getEndpoint(), urlencode($this->domain));
6161
$response = $this->client->request('POST', 'https://'.$endpoint, [
6262
'auth_basic' => 'api:'.$this->key,
6363
'headers' => $headers,

UnsupportedHostException.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ class UnsupportedHostException extends LogicException
4848

4949
public function __construct(Dsn $dsn)
5050
{
51-
$host = $dsn->getHost();
52-
$package = self::HOST_TO_PACKAGE_MAP[$host] ?? null;
51+
$provider = $dsn->getScheme();
52+
if (false !== $pos = strpos($provider, '+')) {
53+
$provider = substr($provider, 0, $pos);
54+
}
55+
$package = self::HOST_TO_PACKAGE_MAP[$provider] ?? null;
5356
if ($package && !class_exists($package['class'])) {
5457
parent::__construct(sprintf('Unable to send emails via "%s" as the bridge is not installed. Try running "composer require %s".', $host, $package['package']));
5558

5659
return;
5760
}
5861

59-
parent::__construct(sprintf('The "%s" mailer is not supported.', $host));
62+
parent::__construct(sprintf('The "%s" scheme is not supported.', $dsn->getScheme()));
6063
}
6164
}

0 commit comments

Comments
 (0)