Laravel 8 doesn't send emails initiated from a job, but when the same e-mail initiated from a controller, everything's fine

Viewed 129

I'm currently trying to find the reason causing my Laravel app not to send emails when I do it from a job (but when I do it from controller, everything works perfectly).

I have a job which ends with an a notification:

$userToSend->notify(new InfoEmail());

This line of code is being executed - I use jdavidbakr/mail-tracker to track emails and it shows this email was sent, but no actual email is delivered. As this line of code is run from a job, and the rest of the code of this job works fine, I'm 100% sure that the queue manager itself is working. $userToSend has all the necessary data - I see it in the log.

When I run the same line of code from a controller, everything works perfectly, and e-mail is delivered.

If I user Mail::to->queue, effects are the same - when it runs from controller, everything works fine, when I do the same in a job - emails are not delivered.

Could you please suggest an idea where to look to resolve this issue?

Here is my mail configuration from .env (### hides actual name of the website which is located at the BlueHost shared hosting)

MAIL_MAILER=smtp
MAIL_HOST=mail.###.com 
MAIL_PORT=465 
MAIL_USERNAME=robot@###.com 
MAIL_PASSWORD=######### 
MAIL_ENCRYPTION=ssl 
MAIL_FROM_ADDRESS=robot@###.com 
MAIL_FROM_NAME="###.com Mail Robot"
0 Answers
Related