This work fine and the email is sent to log(MAIL_DRIVER=log)
and mailtrap.io(MAIL_DRIVER=smtp)
succesfully
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
// running the queue in terminal
php artisan queue:work --queue
then the class implements 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. i don't know what to do.
Well, after many test this is how i solved the problem.
Dont use 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
Mail::to('test@gmail.com')->queue(new VerificationNewAccount($ran));
now the email is sent to gmail
The weird part is that now the email is not printed in log
. Well i dont care. It woks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.