In a recent update to my guide on installing Monica using Docker on Unraid, a few users reported encountering an issue where email reminders were not being sent and I also had the same issue. This issue, tracked on Monica's GitHub under issue #4178, has a straightforward fix that I'll share with you today.
The core of the solution involves running the cron job in a dedicated Docker container. Below, I've shared the Docker-compose and .env file configurations that I am using on my Unraid server. This architecture solves the issue, ensuring your Monica PRM sends out email reminders as expected.
Docker-compose File
🆕 To make it easier to copy/paste/download this code, I've created a repository dedicated to my blog's resources on github. Here's the link to the docker-compose.yml and .env files for this article:
Here's the docker-compose.yml file:
version: "3.9"
services:
app:
image: monica
env_file: .env
depends_on:
- db
ports:
- 8181:80
volumes:
- /mnt/user/appdata/monica-webapp:/var/www/html/storage
restart: always
cron:
image: monica
env_file: .env
restart: always
volumes:
- /mnt/user/appdata/monica-webapp:/var/www/html/storage
command: cron.sh
depends_on:
- db
db:
image: mariadb:11
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=true
- MYSQL_DATABASE=monica
- MYSQL_USER=XXXXXXXXXXXXXXXXX
- MYSQL_PASSWORD=XXXXXXXXXXXXXXXXXXX
volumes:
- /mnt/user/appdata/monica-db:/var/lib/mysql
restart: always
adminer:
image: adminer
restart: always
ports:
- 8282:8080
Environment File (.env)
And here's the .env file configuration:
APP_ENV=local
APP_DEBUG=false
# The encryption key. Must be 32 characters long exactly.
# Use `echo -n 'base64:'; openssl rand -base64 32` to generate a random key.
APP_KEY=XXXXXXXXXXXXXXX
# The URL of your application.
# APP_URL=http://localhost
# Set trusted proxy IP addresses.
# To trust all proxies that connect directly to your server, use a "*".
# APP_TRUSTED_PROXIES=
# Database information
# DB_CONNECTION=mysql
DB_HOST=db
DB_DATABASE=monica
DB_USERNAME=XXXXXXXXXXXX
DB_PASSWORD=XXXXXXXXXXXXXXXXXXXXX
# Mail credentials used to send emails from the application.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.yourmailservice.com
MAIL_PORT=587
MAIL_USERNAME=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
MAIL_PASSWORD=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
MAIL_ENCRYPTION=tls
# Outgoing emails will be sent with these identity
MAIL_FROM_ADDRESS=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
MAIL_FROM_NAME=Monica
LOG_CHANNEL=stderr
CACHE_DRIVER=database
SESSION_DRIVER=database
QUEUE_DRIVER=sync
Important Note: Make sure to replace the placeholder XXXXXXXXXXXXXXX with your actual details for database credentials, app key, mail service configuration, etc. This setup ensures that your Monica instance is correctly configured to send out email reminders without a hitch.
By configuring the cron service in a separate container we ensure that the necessary cron jobs for sending out email reminders are executed reliably.
If you've followed my previous guide on setting up Monica on Unraid and encountered this issue, implementing the above solution should get your email reminders up and running smoothly. For a more in-depth discussion or if you encounter any other issues, don't hesitate to visit the Monica GitHub issue page or reach out using the "Contact-me" form.
Enjoy 😎
AlexIn Tech