问题描述
我正在使用 Queue 在我的应用程序上发送邮件,而且效果很好:
class SendMail implements ShouldQueue
{
use Dispatchable,InteractsWithQueue,Queueable,SerializesModels;
private $user_mail;
private $person_data;
private $title;
private $company_name;
private $html;
private $email_sender;
private $email_reply;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($user_mail,$person_data,$title,$company_name,$html,$email_sender,$email_reply)
{
$this->user_mail = $user_mail;
$this->person_data = $person_data;
$this->title = $title;
$this->company_name = $company_name;
$this->html = $html;
$this->email_sender = $email_sender;
$this->email_reply = $email_reply;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Mail::to($this->user_mail)
->queue(new DocumentMessage($this->person_data,$this->title,$this->company_name,$this->html,$this->email_sender,$this->email_reply));
}
}
现在我想获取队列发送电子邮件时的日志,并按照文档,将此代码放入我的 AppServiceProvider
中进行测试:
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Carbon::setLocale('pt_BR');
setlocale(LC_ALL,'pt_BR');
Carbon::setUtf8(true);
Paginator::useBootstrapThree();
Blade::withoutDoubleEncoding();
Queue::after(function (JobProcessing $event) {
DB::raw("INSERT INTO activity_log (log_name,description,subject_id,subject_type,causer_id,causer_type,properties)
VALUES ('email_sent',now(),null,1111,'App\Models\User','');");
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
但是在我使用我的队列发送邮件后没有任何反应。修改 AppServideProvider 后我应该重新启动我的队列作业还是做一些事情?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)