Laravel 邮件不通过队列发送
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24221563/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Mail Not Sending Via Queue
提问by PaulELI
I just set up a beanstalkd / supervisor config on my server. The queues are working, but when I try and use Laravel's Mail function in conjunction, the emails are not sending.
我刚刚在我的服务器上设置了一个 beanstalkd/supervisor 配置。队列正在工作,但是当我尝试结合使用 Laravel 的邮件功能时,电子邮件没有发送。
I do use gmail for sending out mails, which has not been an issue when using Mail::send in my other normal code. It seems to only not send when I try via a queue.
我确实使用 gmail 发送邮件,在我的其他普通代码中使用 Mail::send 时这不是问题。当我通过队列尝试时,它似乎只是不发送。
Route:
路线:
Route::get('/', function() {
$test = "my name";
Queue::push('DuplicateAccount', $test);
});
Class:
班级:
class DuplicateAccount {
public static function fire($job, $data) {
self::send($data);
$job->delete();
}
public static function send($data) {
$admin = 'MyEmail';
Mail::send('emails.admin.duplicate', array('duplicate'=>$data), function($message) use ($admin) {
$message->to($admin, 'MyName')->subject('Subscription Duplicate');
});
Log::info('a. Mail '.$data.' to '.$admin.'.');
}
}
采纳答案by PaulELI
There was an issue with my mail driver settings apparently. Most likely an issue with gmail and my php.ini configuration when handling the serialization of the queue'd emails.
我的邮件驱动程序设置显然有问题。在处理队列电子邮件的序列化时,很可能是 gmail 和我的 php.ini 配置存在问题。
I changed to smtp and it started to work.
我改为 smtp,它开始工作。
回答by findstar
I think you need to start Queue Listener
我认为您需要启动队列侦听器
php artisan queue:listen
php artisan queue:listen
please visit the link(http://laravel.com/docs/queues#running-the-queue-listener)
请访问链接(http://laravel.com/docs/queues#running-the-queue-listener)