[英]laravel 5.4 Mailable implements ShouldQueue don't sent email
This work fine and the email is sent to log(MAIL_DRIVER=log)
and mailtrap.io(MAIL_DRIVER=smtp)
succesfully这项工作正常,电子邮件成功发送到log(MAIL_DRIVER=log)
和mailtrap.io(MAIL_DRIVER=smtp)
class VerificationNewAccount extends Mailable
{
use Queueable, SerializesModels;
public function __construct()
{
}
public function build()
{
return $this->from('noreply@example.com')
->view('email.verification-request');
}
}
// in controller
Mail::to('test@gmail.com')->send(new VerificationNewAccount());
When i implement ShouldQueue the email is printed in log(MAIL_DRIVER=log)
but when i try to send to mailtrap.io(MAIL_DRIVER=smtp)
the email never is sent当我实现 ShouldQueue 时,电子邮件会打印在log(MAIL_DRIVER=log)
但是当我尝试发送到mailtrap.io(MAIL_DRIVER=smtp)
,电子邮件永远不会发送
// running the queue in terminal
php artisan queue:work --queue
then the class implements ShouldQueue然后该类实现了 ShouldQueue
class VerificationNewAccount extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public function __construct()
{
}
public function build()
{
return $this->from('noreply@example.com')
->view('email.verification-request');
}
}
// in controller
Mail::to('test@gmail.com')->send(new VerificationNewAccount());
There is no error printed in laravel.log file. laravel.log 文件中没有打印错误。 i don't know what to do.我不知道该怎么办。
Well, after many test this is how i solved the problem.好吧,经过多次测试,这就是我解决问题的方法。
Dont use ShouldQueue
不要使用ShouldQueue
class VerificationNewAccount extends Mailable
{
use Queueable, SerializesModels;
public function __construct()
{
}
public function build()
{
return $this->from('noreply@example.com')
->view('email.verification-request');
}
}
Instead use the basis ->queue
而是使用基础->queue
Mail::to('test@gmail.com')->queue(new VerificationNewAccount($ran));
now the email is sent to gmail
现在电子邮件已发送到gmail
The weird part is that now the email is not printed in log
.奇怪的是,现在电子邮件没有打印在log
。 Well i dont care.好吧,我不在乎。 It woks!好用!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.