'Laravel queue jobs are working fine but mails are not getting delivered
I'm building an application in Laravel 8 and when I try sending emails directly from the controller, emails are getting sent but when I try to send mails from jobs, the jobs are working fine and there is no entry in failed jobs table but I'm not getting emails.
So functionality is whenever the user register he will get a mail and for that, I'm trying to send mail from jobs so that my load time will be reduced.
Here is my code from controller
$userDetails = ['name' => $userSocial->getName()];
Mail::to($userSocial->getEmail())->send(new welcomeMail($userDetails));
Here is code from mailable
class welcomeMail extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public $userDetails;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($userDetails)
{
$this->userDetails = $userDetails;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$name = $this->userDetails['name'];
return $this->subject('Welcome, we are glad to have you onboard.')->view('mail.welcomeMail',['name' => $name]);
}
}
Everything is working fine my only concern is I'm not getting emails. Any lead would be appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
