🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 将邮件消息加入队列 发送电子邮件消息会大幅延长应用程序的响应时间,因此许多开发者选择将邮件消息加入队列并于后台发送。 Laravel 使用内置 统一的 queue API ,让您轻松地完成此工作。要将邮件消息加入队列,只要使用 Mail 类的 ## queue 方法: ~~~ Mail::queue('emails.welcome', $data, function($message) { $message->to('foo@example.com', 'John Smith')->subject('Welcome!'); }); ~~~ 您也可以使用 later 方法来指定您希望延迟发送邮件消息的秒数: ~~~ Mail::later(5, 'emails.welcome', $data, function($message) { $message->to('foo@example.com', 'John Smith')->subject('Welcome!'); }); ~~~ 若您想要指定特定的队列或「管道」来加入消息,您可使用 queueOn 以及 laterOn 方法: ~~~ Mail::queueOn('queue-name', 'emails.welcome', $data, function($message) { $message->to('foo@example.com', 'John Smith')->subject('Welcome!'); }); ~~~