Dynamic mail configuration with values from database [Laravel]

后端 未结 3 1591
傲寒
傲寒 2021-02-01 07:09

I have created a service provider in my Laravel Application SettingsServiceProvider. This caches the settings table from the database.

$settings = $         


        
3条回答
  •  遥遥无期
    2021-02-01 07:49

    Following the instructions here is the proper solution to the problem, in case if you're sending multiple emails per request over different SMTP configurations, Config::set() won't work right, the first email will use the correct settings, while all upcoming emails within the same request will use the same configuration of the first one, because the Mail service is provided as a singleton thus only the initial configurations will be used.

    This also might affect emails sent over Laravel queue workers due to the same reason.

提交回复
热议问题