Open oliverskawronek opened 9 months ago
I did a little research on getHttpClient.
Guzzle as HTTP client was replaced by this pull request: https://github.com/laravel/framework/pull/45684 This is part of Laravel 9.x
I think the best way would be to allow a client
option in the mail.php config:
'azure' => [
'transport' => 'azure',
'resource_name' => env('AZURE_MAIL_RESOURCE_NAME'),
'endpoint' => env('AZURE_MAIL_ENDPOINT', 'https://my-acs-resource-name.communication.azure.com'),
'access_key' => env('AZURE_MAIL_KEY'),
'api_version' => env('AZURE_MAIL_API_VERSION', '2023-03-31'),
'disable_user_tracking' => env('AZURE_MAIL_DISABLE_TRACKING', false),
'client' => [
// ..
]
],
and pass $config
to getHttpClient
:
return new AzureMailerApiTransport(
$config['endpoint'],
$config['access_key'],
$config['api_version'],
boolval($config['disable_user_tracking']),
$this->getHttpClient($config),
);
But if the client
array is not set or empty, a null
HttpClient would still returned.
This behaviour from Laravel's MailManager#getHttpClient
doesn't make sense to me, but how about this?:
// If no client options are set or empty, use default options.
if (!isset($config['client']) || empty($config['client'])) {
$config['client'] = HttpClientInterface::OPTIONS_DEFAULTS;
}
I'am sorry, this is about v0.2.2 and now I realize that v0.3.0 is the current stable version :(
I just run composer require hafael/azure-mailer-driver
and v0.2.2 was installed on my project due to v0.3.0 uses symfony/azure-mailer and this package has no stable version.
If you don't want to maintain v0.2.2 its ok to close this issue.
I have this issue as well. I ran composer update
and it bumped me from v0.2.1 to v0.2.2. Once upgraded I started getting the null mailer client issue.
I attempted to upgrade to v0.3.0 but unfortunately that requires PHP 8.2 which I am currently using v8.1 for other reasons. (Azure app services / devops pipelines are stuck on 8.1 currently).
The ultimate solution for me at this time is temporarily to downgrade the mailer package back to v0.2.1 for now. Just sharing in case anyone else has this problem.
Environment:
Error:
Please have look at
AzureMailerManager
This method calls
getHttpClient
with an empty array.But if you look at
MailManager
, with an empty array, the HttpClient will be always null:When I replace it with
HttpClient::create([], 3, 3)
I'am able to send an email successfully.But I don't know, what would be the right options for
getHttpClient
. So I will not create a pull request.