My Nextcloud server won´t stop sending activity emails

Nextcloud version: 18.0.4 - 18.0.4.2
Operating system and version: Linux 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64
Apache or nginx version: Apache/2.4.38 (Debian) (apache2handler)
PHP version: 7.3.14-1~deb10u1

The issue you are facing:

My nextcloud server was running for half an year on “ajax” background tasks and was configured to send hourly emails, but now i have configured system cron jobs an week ago and i think my server wants to send now all missed emails. I get every 20 minutes an email with the latest notifiable activities which are 50 since i installed the server. At the moment i have disabled email notification in the admin section and i still get one mail after the other. To the moment i got 500 emails with all the activities and when i do something new it is added to the list with the next email.

Is there a possibility to delete the email queue or force all emails to send at once and have normal functionality after that?

Is this the first time you’ve seen this error? (Y/N): Yes

The output of your Nextcloud log in Admin > Logging: nothing visible in the logs to that

The output of your config.php file in /path/to/nextcloud:

`<?php
$CONFIG = array (
  'instanceid' => 
  'passwordsalt' => 
  'secret' => 
  'trusted_domains' =>
  array (
  ),
  'datadirectory' =>
  'dbtype' => 'mysql',
  'version' => '18.0.4.2',
  'overwrite.cli.url' => '
  'dbname' => 
  'dbhost' => 
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 
  'dbpassword' => 
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'htaccess.RewriteBase' => '/',
  'mail_domain' => '',
  'mail_from_address' => '',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => '',
  'mail_smtpport' => '25',
  'maintenance' => false,
  'has_rebuilt_cache' => true,
  'theme' => '',
  'loglevel' => 2,
  'app_install_overwrite' =>
  array (
    0 => 'keeporsweep',
  ),
);`

The output of your Apache/nginx/system log in /var/log/____:


[Thu Apr 30 00:00:01.941463 2020] [mpm_prefork:notice] [pid 29925] AH00163: Apache/2.4.38 (Debian) OpenSSL/1.1.1d configured -- resuming normal operations
[Thu Apr 30 00:00:01.941517 2020] [core:notice] [pid 29925] AH00094: Command line: '/usr/sbin/apache2'
[Thu Apr 30 10:52:37.863518 2020] [php7:error] [pid 22776] [client 5.101.0.209:49066] script '/var/www/Zertifikat/index.php' not found or unable to stat
[Thu Apr 30 10:58:18.852702 2020] [php7:error] [pid 19261] [client 159.203.37.96:28492] script '/var/www/Zertifikat/index.php' not found or unable to stat
[Thu Apr 30 17:25:38.299304 2020] [access_compat:error] [pid 19759] [client [Gateway IP Adress]:50629] AH01797: client denied by server configuration: /var/www/apache/nextcloud/config
[Fri May 01 00:00:02.383330 2020] [mpm_prefork:notice] [pid 29925] AH00171: Graceful restart requested, doing restar

Ok, my server stopped today the spamming after 744 emails.

I also found a command in the activity documentation which could help others if they run into the same issue.

[path_to_nectcloudroot]/occ activity:send-mails

Thanks to everyone who took their time and read my issue.

Best regards
DARKDacil

Okay i thought it was finished. Enabled emails again and deleted a folder as test. I got 70 emails as info about it today every 20 minutes and i can´t force it with the mentioned command.

I´m open for suggestions again and i will read me through the activity documentation in that time again. Thanks for everyones time who is taking a look into my problem.

best regards
DARKDacil

If you have just one main user: You change your personal notification settings for each user in the personal settings. I’d disable the mail notifications, turn it globally on. Then wait a bit to make sure the cronjob runs properly (perhaps there are other things in the queue after which it triggers a mail being sent out). Then try to turn on via the personal page again the notifications you’d like to have.

Just wanted to give you an update so far. I’ve unchecked all email notifications in admin and personal. Set the send mail option to as soon as possible and then deactivated the general option to send emails about activities. This was 28 hours ago and I still wait that he stops sending me emails.

I also configured the logs now to debug and I found an error in the apcu cache, but fixed it yesterday evening.

That sounds strange. Are these mails for the same events? Like, does it seem that it doesn’t register what mails were already sent out last time?
Check the logs especially regarding the cronjob. Perhaps run the cronjob manually from command line to see if there are errors (perhaps it creates the mails and then fails with an error):
sudo -u www-data php -f cron.php

The emails are for the same events. When i do something new he adds it to the activity list with the next mail and continues to send this list every 20 minutes.

I tried instant notification and hourly so far as frequencies. At both frequencies are the same intervals.

I found out i can stop the spamming when i delete my mail adress in myprofile. After that i can enter my mail adress again and then he don´t send mails until i do my first notifyable event and in this emails the old activities are deleted.

It will not send more emails if i start the cron.php manually, when i read it right he has a 15 minute cooldown programmed on activity mails and this cooldown is working.

I can force the sending with the following commands:
php -f /var/www/nextcloud/occ activity:send-mails hourly
php -f /var/www/nextcloud/occ activity:send-mails daily
php -f /var/www/nextcloud/occ activity:send-mails weekly

I configured my logs on debug level and i see now errors when he sends a mail.

best regards
DARKDacil

Ok, i think i found the problem on my server. Today i found the following addition on github to the activity app: https://github.com/madmas/activity/commit/e85a42fae2fc5c65ac75d655dab64be13e32790a

And now i got the debug log that my smtp server is timing out while sending the mails. Today i have now time left, but tomorrow i will fix it and i will inform you if it fixed the problem.

Best regards
DARKDacil

Okay i reconfigured my SMTP settings now and it solved the problem.

It seems that my nextcloud could reach my smtp server, but not otherwise and so he didn´t get the info that i already got that mail.

The added code for the logging really helped me there.

Thanks to everyone who tried to help me.

Best regards
DARKDacil