Mail configuration file for each tenant
Hello, how can I configure the sending of mail for each of the tenants? That each tenant manages its own mail configuration file
You would build all that into your app's code at the tenant layer. Essentially:
- in your app build some sort of way to store configuration settings unique to each tenant
- then retrieve and set the configuration whenever the tenant is activated
This would likely include things like:
- tenant-side migrations, models, etc for storing configuration settings records in the tenant's database
- maybe create a ConfigServiceProvider to read all the config settings from the db and add them into Laravel's configuration registry with the config() helper or Config facade
- alternatively maybe listen for the tenant Switched event (see the docs) and swap settings at that point
Hello thanks for the valuable help. Configure the application as indicated
- I have created the ConfigServiceProvider class and within the method I call my ConfigurationMailServer class that contains the configuration for sending emails.

- Register provider
Once all the configuration is done I receive a message in the console when I execute the following command:
$ php artisan config: cache

I faced a similar problem recently. Instead of using a Service Provider, use a Middleware. For some reason, the boot method on the Sevice Provider runs before a tenant has been identified. So use a middleware but make sure it is not global middleware on Kernel because it will run on every request. Assign that middleware to only one route that is going to trigger that email sending.