【发布时间】:2021-01-18 21:38:05
【问题描述】:
在我的 Laravel 应用程序中,我尝试根据登录用户的 company_id 发送邮件通知:
我有这个:
$mail=DB::table('mail_settings')->first();
$config = array(
'driver' => $mail->driver,
'host' => $mail->host,
'port' => $mail->port,
'from' => array('address' => $mail->from_address, 'name' => $mail->from_name),
'encryption' => $mail->encryption,
'username' => $mail->username,
'password' => $mail->password,
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false
);
Config::set('mail',$config);
型号
class Company extends Model
{
protected $table = 'companies';
protected $fillable = [
'id',
'organization_name'
];
}
class User extends Authenticatable
{
protected $fillable = [
'name',
'company_id',
'email',
];
}
有没有办法在创建邮件传输之前即时覆盖默认邮件配置(在 app/config/mail.php 中)(例如,配置存储在数据库中)?
谢谢
有没有办法重新创建 laravel swiftmailer 传输,以便它可以获取更新的配置值?
【问题讨论】:
标签: laravel