您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

laravel5.1 使用队列发送邮件

2025/10/31 21:40:55发布18次查看
首先在`.env`文件下设定队列的驱动```queue_driver = database```laravel5.1提供了6种驱动,`sync`,`databse`,`beanstalkd`,`sqs`,`iron`,`redis`具体可以在官方手册查阅.本次选用`database`作为驱动php cli下执行```php artisan queue:tablephp artisan queue:failed-tablephp artisan migrate```生成了两个表,存放队列的成功的数据和失败的数据然后在`app/config/mail.php`下设置发信人的账户和名称`'from' => ['address' => 'xxx@163.com', 'name' => 'fuck it']`在`.env`下设置邮箱的相关信息```mail_driver=smtpmail_host=smtp.163.commail_port=25mail_username=邮箱账户mail_password=邮箱密码mail_encryption=null```__确认你的邮箱已经开启了smtp服务__配置发送路由```route::get('mail/queue',function(){ mail::later(5,'emails.queued_email',[name => gewenrui],function($message){ $message->to('收件人邮箱','名称')->subject('主题'); }); return get emails;});```在`views/emails/queue`下新建模板php cli 下执行`php artisan queue:listen`web下访问`mail/queue`这个路由可以发现`processed: mailer@handlequeuedmessage`发送成功
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product