monicahq / monica

Personal CRM. Remember everything about your friends, family and business relationships.
https://beta.monicahq.com
GNU Affero General Public License v3.0
21.52k stars 2.15k forks source link

No reminders e-mails #4178

Open peetersdaan opened 4 years ago

peetersdaan commented 4 years ago

Hi all,

Currently, I am running MonicaHQ on my Synology DS418:Play (through Portainer). I have managed to set up the SMTP server, which works (i.e. I receive e-mails when inviting users to the system). However, when setting a reminder for a certain person, I do not get any e-mails. I have already tried changing the time that the system sends the reminders.

Monica Version: 2.18.0

environment:

generate with pwgen -s 32 1 for instance:

  - APP_KEY=
  - DB_HOST=db
  - DB_DATABASE=monica_db
  - DB_USERNAME=monica-user
  - DB_PASSWORD=secret
  - MAIL_MAILER=smtp
  - MAIL_HOST=smtp.gmail.com
  - MAIL_PORT=587
  - MAIL_ENCRYPTION=tls
  - MAIL_USERNAME=
  - MAIL_PASSWORD=
  - MAIL_FROM_ADDRESS=
  - MAIL_FROM_NAME="Monica Personal CRM"
peetersdaan commented 4 years ago

I've managed to make it work to add - CRON_LEGACY=true to the environment of my docker-compose.yml. However, as it is not ideal to run cron in the container I want to install supervisor. https://github.com/monicahq/monica/tree/master/scripts/docker/.examples

Unfortunately, I am not able to set up supervisor.

deferredreward commented 4 years ago

I also have email configured properly (it seems, as I get sign up mails and when I run the new test command it works), but don't get reminder emails. I'm running in a VPS Ubuntu 18, standard linux setup. Happy to submit any config or logs by request.

asbiin commented 4 years ago

@deferredreward did you try using supervisord like in the example section? https://github.com/monicahq/monica/tree/master/scripts/docker/.examples/supervisor

kingcc commented 3 years ago

I have same issue, has there been any progress since the last reply?

zeezhao commented 3 years ago

Hi - same issue here - not getting reminders. I am running a self-hosted v2.19.1

I have tested email using: php artisan monica:test-email and that works.

But daily and birthday reminders are not working (i.e. no emails received) via running: php artisan schedule:run [this gives output e.g. "Running scheduled command: "php.exe" "artisan" send:reminders > "NUL" 2>&1... and so on]

The main difference is I am testing a self-hosted v2.19.1 on Windows 10 using xampp with php7.4.15.

Please - any ideas? Thanks

meijbaard commented 3 years ago

Is there a possibility you're user_id is changed? I had the same issue and this came because of the fact after upgrading my new user account had id 5 instead if id 1. So the job couldn't find the right emailaddress, because id 1 wasn't in the database available anymore.

I fixed this to do un update in the table reminder_outbox and changed the user_id;

zeezhao commented 3 years ago

@meijbaard, thanks for the tip - it now works! I fixed the users table so that it matches accounts & reminder_outbox tables. I guess a bug in the upgrade... Thanks for your help!

edit: The only reminders now not received are the "Stay in touch" reminders I had set to daily. But this may be a separate issue...

peetersdaan commented 3 years ago

@meijbaard, thanks for the tip - it now works! I fixed the users table so that it matches accounts & reminder_outbox tables. I guess a bug in the upgrade... Thanks for your help!

edit: The only reminders now not received are the "Stay in touch" reminders I had set to daily. But this may be a separate issue...

@zeezhao, recently I reinstalled Monica, however I am also still facing this issue.

zeezhao commented 3 years ago

@peetersdaan - not getting any reminders at all? If so, as suggested above, make sure the id=1 in user table exists and aligns with account table. To do that I had to do manual updates in sql, and actually had to truncate some tables like reminder table to avoid index violation errors. But since it is just a test installation for me, it did not matter for me.

If it is just the "stay in touch" reminders, I have not figured that out yet. I can't even see them stored in any table. So that may be a genuine bug.

It is also crucial to make sure that monica can send mails anyway using this command, which can send a test email to an address of your choice: php artisan monica:test-email

If that does not work, then your monica environment needs to be properly setup for emails.

Hope this helps...

edit: I actually got the "Stay in touch" emails. They were in junkbox. So it works correctly. Please ignore comment related to this. Thanks

peetersdaan commented 3 years ago

@zeezhao, I just reinstalled Monica completely.

php artisan monica:test-email works, however, php artisan send:stay_in_touch not.

meijbaard commented 3 years ago

This command only will send reminders that are in the range of 7/30 days I guess. So if there are no reminders to be send, then this will give no output.

You can check your database table reminders_outbox, to see if everything is there.

zeezhao commented 3 years ago

What I also found is that the "stay in touch" reminders do not always work.... I have a few daily ones set but do not always get the email after running the cron job. I can't even see where they are stored in the database i.e. "stay in touch" reminders.

Normal reminders exist in the reminder_outbox table, and I can see those.

iloveitaly commented 3 years ago

@zeezhao the stay_in_touch data is stored on two columns on the contact database.

I ran into issues here as well. Here's the docker config that fixed the issue on my raspberry pi.

onetrickwolf commented 3 years ago

Hey having this issue too. I am running docker with supervisord and the email test works as well as forget password emails but it seems like general reminders and stay in touch reminders do not.

I tried setting a bunch of reminders organically and never got them after a few days besides them being set to send daily. After that I tried running the commands directly.

Running php artisan send:stay_in_touch does nothing no output and no emails.

Running php artisan schedule:run gives "No scheduled commands are ready to run."

Looking at the database it looks like my user ID is 1 and this is a fresh install so don't think it's that issue. I see reminders in the outbox.

I see the stay in touch trigger dates in the contacts table and tried setting the trigger to a time in the past and running php artisan send:stay_in_touch but all it does is update the trigger time to the next day but does not actually send the email. Not in spam and checking AWS SES does not show any emails sent.

If anyone has any ideas on how to further debug let me know I have been playing around with it for a few days and am stumped.

onetrickwolf commented 3 years ago

Kind of odd but I changed nothing since my last post but left the instance running and received one stay in touch reminder today. Funny though I have a stay in touch reminder set for many people daily and only got it for one person today and this is after several days have passed. I also set up some manual reminders that have still never sent.

Logs don't look any different from last couple of days where nothing sent, just keep seeing stuff like this:


crond:  line php /var/www/html/artisan schedule:run -v
crond: wakeup dt=60
crond: file www-data:
crond:  line php /var/www/html/artisan schedule:run -v
crond: wakeup dt=60
crond: file www-data:
crond:  line php /var/www/html/artisan schedule:run -v
crond:  job: 0 php /var/www/html/artisan schedule:run -v
crond: child running /bin/bash
crond: USER www-data pid 2565 cmd php /var/www/html/artisan schedule:run -v
crond: wakeup dt=10
[2021-07-15 17:00:11][52] Processing: App\Jobs\StayInTouch\ScheduleStayInTouch
[2021-07-15 17:00:11][52] Processed:  App\Jobs\StayInTouch\ScheduleStayInTouch
[2021-07-15 17:00:11][53] Processing: App\Jobs\StayInTouch\ScheduleStayInTouch
[2021-07-15 17:00:11][53] Processed:  App\Jobs\StayInTouch\ScheduleStayInTouch
[2021-07-15 17:00:12][54] Processing: App\Notifications\StayInTouchEmail
[2021-07-15 17:00:14][54] Processed:  App\Notifications\StayInTouchEmail
crond: wakeup dt=50
crond: file www-data:
crond:  line php /var/www/html/artisan schedule:run -v
crond: wakeup dt=60
crond: file www-data:
crond:  line php /var/www/html/artisan schedule:run -v```

Very odd problem if anyone has any ideas. My network and server are all pretty normal and other docker containers aren't have any problem.
onetrickwolf commented 3 years ago

Okay I guess final update from me but just finding reminders really inconsistent but they seem to be working now? Not sure if there are special rules for reminders being sent out or something (if you visit the person's page do you not get a stay in touch reminder or something?) but I am getting enough now for it to be usable after a few days.

I have two test instances of Monica running with pretty much the exact same people and reminders. One is a Heroku app and one is running in Docker on a local server.

The local instance did not send reminders out for the first day or two and now is doing it consistently. The Heroku app gives me reminders on and off...I assume this might have something to do with Heroku putting unused apps to sleep and the scheduler not being able to wake it up properly or something.

Anyway the local instance is working fine enough for my liking now. Wish I could help other people having this problem but I honestly did not change anything, just left it running for a few days.

b3nd1k commented 2 years ago

Okay I guess final update from me but just finding reminders really inconsistent but they seem to be working now?

Did you do anything to get it working @onetrickwolf? I have been running Monica for a few months, but have not been able to get it working. I'm running Monica in Docker on my server. php artisan monica:test-email works, but nothing else.

onetrickwolf commented 2 years ago

@b3nd1k unfortunately I have no idea what I did. I tried a bunch of different things and it seemed like none of it worked then suddenly was just working some days later after changing nothing. It worked consistently until about last month and now again I have no idea why it's not working. It doesn't seem to line up with any updates or anything specific I changed. I have this issue across different types of installations and different email services etc. Checked spam folder etc.

I haven't dug as deep as I could though.

meijbaard commented 2 years ago

Same issue here. Fresh installation, no notifications.

DId a clean install today with a new import of only contacts. Just looking if this is working.

peetersdaan commented 2 years ago

Just a small update, in the past I made it work by using the apache supervisor and by placing the ./app in the correct docker folder on my Synology.


version: "3.4"

services:
  app:
    build: ./app
    image: monica-app
    depends_on:
      - db
    environment:
      - APP_KEY=
      - DB_HOST=db
      - TZ=Amsterdam/Europe
      - MAIL_MAILER=smtp
      - MAIL_HOST=smtp.gmail.com
      - MAIL_PORT=587
      - MAIL_ENCRYPTION=tls
      - MAIL_USERNAME=
      - MAIL_PASSWORD=
      - MAIL_FROM_ADDRESS=
      - MAIL_FROM_NAME="Monica Personal CRM"
      - APP_URL=
      - APP_ENV=
      - QUEUE_CONNECTION=database
      - PUID=
      - GUID=
    ports:
      - 8080:80
    volumes:
      - /volume1/docker/monica/data:/var/www/html/storage
    restart: always

  db:
    image: mysql:5.7
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=true
      - MYSQL_DATABASE=
      - MYSQL_USER=
      - MYSQL_PASSWORD=
    volumes:
      - /volume1/docker/monica/db:/var/lib/mysql
    restart: always
zeezhao commented 2 years ago

Same issue here on a fresh installation. Reminders on an old one stopped too a while back... I have left it for now.

Same issue here. Fresh installation, no notifications.

DId a clean install today with a new import of only contacts. Just looking if this is working.

meijbaard commented 2 years ago

I did that also. It is working. I now get them twice :) Let me know if you face the same.

zeezhao commented 2 years ago

I ran it manually using: php artisan schedule:run

and it now works again.

I noticed that it is very sensitive to the "Time of the day reminders will be sent " setting.

If for any reason cron did not work and you try and run it manually after the time setting has passed, it may not work. I would have expected code to still run provided it has not run at all for the day.

Fardenz commented 1 year ago

I relate to this issue, by running the docker with the env flag CRON_LEGACY=true or running the php artisan send:stay_in_touch script it seems like the stay in touch dates are updated, but no emails are sent. I do get the export complete and forgot password emails.

image

chevdor commented 8 months ago

Same issue here. php artisan monica:test-email works fine. I tried the CRON_LEGACY option, I tried to run a second container running cron.sh, I tried changing the delivery time, I checked accounts id... other than php artisan monica:test-email, no email is even sent.

AlexIn-Tech commented 8 months ago

@zeezhao the stay_in_touch data is stored on two columns on the contact database.

I ran into issues here as well. Here's the docker config that fixed the issue on my raspberry pi.

Hello everyone,

I can confirm the following solution works great. I am running it on Unraid as a docker stack. I use adminer to manage the DB but you can remove it if you don't need it. Here is my docker-compose file and my .env file :

docker-compose 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

.env file : I don't use the things in comments but you could if you wish.

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

I hope it helps 🤓

chevdor commented 8 months ago

I think the main issue overall is the lack of proper logging of the errors. Many people run the php artisan monica:test-email and it works while the rest does not. There should be a log showing what is done, that would help people realize it is the wrong email or user, for instance.

As you did @AlexIn-Tech I did add a container running cron.sh, after realizing that running the main container was not enough.

A solution to that issue would be the the last cron run is show somehow with some php artisan monica:cron-stats. If the last run is never, it would be clear that the user does not run cron with one of the available strategies. If the last run was 1h ago but no email was sent, the user can dig further in the logs.

rama31244 commented 4 months ago

@zeezhao the stay_in_touch data is stored on two columns on the contact database. I ran into issues here as well. Here's the docker config that fixed the issue on my raspberry pi.

Hello everyone,

I can confirm the following solution works great. I am running it on Unraid as a docker stack. I use adminer to manage the DB but you can remove it if you don't need it. Here is my docker-compose file and my .env file :

docker-compose 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

.env file : I don't use the things in comments but you could if you wish.

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

I hope it helps 🤓

Hi I also run monica on unraid but via the container template rather than using docker compose. Can I modify the template in the edit screen to implement this solution? Or do i need to use docker compose? Thanks