Fix the Issue of Flarum Emails Not Being Sent Due to Queue.
Introduction
Recently, while configuring Flarum, I encountered a peculiar issue where users were not receiving emails despite the Email SMTP configuration being correct. This included, but was not limited to, registration activation, password recovery, notifications, etc.
Cause of the Issue
After searching through the sending logs, I discovered that this problem did not exist a few months ago. Reviewing my recent operations and community feedback, I narrowed the issue down to the Queue. In Redis sessions, cache & queues, there is mention of the Queue. I overlooked this when initially using Redis.
Solution
One approach is to execute php flarum queue:work
, as suggested. However, this command opens an uninterrupted window, and we can use a process guardian to ensure it runs correctly. My Flarum instance runs in a Docker container, which is inconvenient for me. Nevertheless, we can run it first to see if it resolves the email sending issue.
|
|
I observed that emails were sent correctly after execution, confirming that the issue was due to the Queue not running properly.
The second method, which I ultimately adopted, involves a small plugin provided by Database Queue - the simplest queue, even for shared hosting. This plugin uses Cron tasks to handle the Queue, requiring only that Cron runs normally.
To install the plugin, since I am in a Docker container, I reconstructed the command:
|
|
flarum
is the name of my container; you can modify it accordingly.
Then, restart Flarum and check if Cron has been correctly added. You should see something similar to:
|
|
'/usr/bin/php8' 'flarum' queue:work --stop-when-empty
is what we expect, indicating no issues.
Remember to add Cron if you haven’t already. You can refer to my example. First, enter crontab:
|
|
Add:
|
|
Conclusion
Barring any unforeseen circumstances, you should have resolved the issue of emails not being sent. If emails still fail to send, it may be a configuration issue. Ensure the SMTP information is correct before starting and test it.
References
Related Content
- Use Docker Compose to Deploy the LobeChat Server Database Version
- Migrate the Docker-Deployed Umami From One Server to Another.
- Deploying a Full-Stack Excalidraw Using Docker
- CSCI 1100 - Homework 8 - Bears, Berries, and Tourists Redux - Classes
- CSCI 1100 - Homework 7 - Dictionaries