feat: register dynamic mailers in AppServiceProvider, remove single-azure methods from SettingsController

This commit is contained in:
ghassan committed 2026-05-26 12:26:02 +03:00
1 parent 8d336466f4
commit db5272dd1d
2 files changed
+14 -77

No files matched your search

+13 -10
View File
@@ -2,23 +2,16 @@
namespace App\Providers;
use App\Models\MailAccount;
use App\Models\Setting;
use Illuminate\Mail\MailManager;
use Illuminate\Support\ServiceProvider;
use PromoSeven\UltraMessage\Facades\UltraMessage;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
public function register(): void {}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
UltraMessage::configUsing(function () {
@@ -31,5 +24,15 @@ class AppServiceProvider extends ServiceProvider
'enabled' => (bool) Setting::get('ultramsg_enabled', config('ultra-message.enabled', true)),
];
});
$this->callAfterResolving(MailManager::class, function (MailManager $manager) {
try {
foreach (MailAccount::all() as $account) {
$manager->extend($account->name, fn () => $account->buildTransport());
}
} catch (\Exception) {
// DB not ready on fresh install — skip silently
}
});
}
}