tenancy / multi-tenant

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant
https://tenancy.dev
MIT License
2.56k stars 393 forks source link

Mail configuration file for each tenant #965

Open pcodetm opened 4 years ago

pcodetm commented 4 years ago

Hello, how can I configure the sending of mail for each of the tenants? That each tenant manages its own mail configuration file

drbyte commented 4 years ago

You would build all that into your app's code at the tenant layer. Essentially:

This would likely include things like:

pcodetm commented 3 years ago

Hello thanks for the valuable help. Configure the application as indicated

  1. I have created the ConfigServiceProvider class and within the method I call my ConfigurationMailServer class that contains the configuration for sending emails.

image

  1. Register provider image

Once all the configuration is done I receive a message in the console when I execute the following command:

$ php artisan config: cache

image

richardkeep commented 3 years ago

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.