1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 02:54:03 +00:00

Update MailConfigBootstrapper.php

while running in queue:work previosly it was not working made this changes now it is working fine
This commit is contained in:
Paras Suthar Darji 2025-07-15 11:36:34 +05:30 committed by GitHub
parent 62624275cc
commit 0d83ba28d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,9 +43,19 @@ class MailConfigBootstrapper implements TenancyBootstrapper
static::$credentialsMap = array_merge(static::$credentialsMap, static::$mapPresets[static::$mailer] ?? []); static::$credentialsMap = array_merge(static::$credentialsMap, static::$mapPresets[static::$mailer] ?? []);
} }
public function bootstrap(Tenant $tenant): void public function bootstrap(Tenant $tenant): void
{ {
// Forget the mail manager instance to clear the cached mailers // Clear the mail manager and its cached mailers
if ($this->app->bound('mail.manager')) {
$mailManager = $this->app->make('mail.manager');
// Clear all cached mailer instances
$reflection = new \ReflectionClass($mailManager);
$mailersProperty = $reflection->getProperty('mailers');
$mailersProperty->setAccessible(true);
$mailersProperty->setValue($mailManager, []);
}
$this->app->forgetInstance('mail.manager'); $this->app->forgetInstance('mail.manager');
$this->setConfig($tenant); $this->setConfig($tenant);
@ -55,6 +65,16 @@ class MailConfigBootstrapper implements TenancyBootstrapper
{ {
$this->unsetConfig(); $this->unsetConfig();
// Clear cached mailers again
if ($this->app->bound('mail.manager')) {
$mailManager = $this->app->make('mail.manager');
$reflection = new \ReflectionClass($mailManager);
$mailersProperty = $reflection->getProperty('mailers');
$mailersProperty->setAccessible(true);
$mailersProperty->setValue($mailManager, []);
}
$this->app->forgetInstance('mail.manager'); $this->app->forgetInstance('mail.manager');
} }