I have trying to send mail using Laravel queue job, and my site on hostmonster web server but it is not sending mail when I fire php artisan queue:work
, It clears Job table but not mail received to my email address.
Here is my code to queue and send mail function:
//It is working
$to = '****@g***l.com';
\Mail::to($to)->send(new ContactUsMail($contactUsId));
//It is not working: on same host email working not work with hotmail - gmail - other
$to = '****@g***l.com';
\Mail::to($to)->queue(new ContactUsMail($contactUsId));
The mail send working fine with 2 case:
send()
method (bypass/ignore queue) queue()
send to same hosting email (like [email protected]
)But now if I use [email protected]
/[email protected]
then in such case queue not working - job table also delete entry as mail sent but bingo..!! where mail send I don't know.
Also cron mail same problem as queue simple mail()
function working there not Mail::send()
work there..!
After many tries I have found solution with my server that is below setting working fine :
.env
file setup MAIL_DRIVER=sendmail
.
config/mail.php
file 'sendmail' => '/usr/sbin/sendmail -t'
replace -bs
with -t
.
php artisan queue:work
.QUEUE_DRIVER=sync
to QUEUE_DRIVER=redis
or QUEUE_DRIVER=database
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With