简体   繁体   中英

Laravel7 + Queue & Supervisor => Mails are not sent

I am using Queue to send out an order confirmation asynchronous and not make the user wait for payment completion in the frontend. This works fine when using php artisan queue:work - everything is processed as it should.

Now when I want to let supervisor handle the sending, the jobs fail consistently with the following exception:

[2020-08-17 19:54:12] production.ERROR: Cannot send message without a sender address {"exception":"[object] (Swift_TransportException(code: 0): Cannot send message without a sender address at /var/www/backend/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:195)

This obviously states that there is no sender address configured in .env . However there is, as well as in config/mail.php . I assume that supervisor can not read the global MAIL_FROM_ADDRESS in .env or has no access to .env but I am not certain how to achieve that.

This is my supervisor config (as instructed in Laravel Docs ):

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/backend/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/backend/worker.log
stopwaitsecs=3600

I am using QUEUE_CONNECTION=database . The server is running nginx on ubuntu.

I also already tried to let supervisor use user=root without success.
Did anyone experience something similar?

Try setting a directory:

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
directory=/var/www/backend
command=php artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/backend/worker.log
stopwaitsecs=3600

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM