// 生成任务文件
php artisan make:job SendEmail
// app/Jobs/SendEmail.php
class SendEmail extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
protected $email;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($email)
{
//
$this->email = $email;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
Mail::raw('队列测试', function($message) {
$message->from('admin@zohar.com.cn', 'zohar');
$message->subject("Study in Zohar's blog");
$message->to($this->email);
});
}
}