Failed creating activity email for one specific user: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)

Nextcloud version : 28.0.0
Operating system and version: Ubuntu 22.04.3 LTS
Apache or nginx version: Apache/2.4.52 (Ubuntu)
PHP version: PHP 8.1.2-1ubuntu2.14

The issue you are facing:

Since updating Nextcloud from v20 to v28 and migration to a new server, our logfile is full of messages like this, but only for one specific user. I can’t find where to set the timezone used for the activity report for a specific user.

Exception
DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)
Failed creating activity email for user "User123"

Is this the first time you’ve seen this error? Y

The output of your Nextcloud log in Admin > Logging:

{"reqId":"dMViyuSffVAs0F7a0dlp","level":3,"time":"2023-12-18T11:45:03+00:00","remoteAddr":"","user":"--","app":"activity","method":"","url":"--","message":"Failed creating activity email for user \"User123\"","userAgent":"--","version":"28.0.0.11","exception":{"Exception":"Exception","Message":"DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/activity/lib/MailQueueHandler.php","line":329,"function":"__construct","class":"DateTimeZone","type":"->"},{"file":"/var/www/nextcloud/apps/activity/lib/MailQueueHandler.php","line":130,"function":"sendEmailToUser","class":"OCA\\Activity\\MailQueueHandler","type":"->"},{"file":"/var/www/nextcloud/apps/activity/lib/BackgroundJob/EmailNotification.php","line":60,"function":"sendEmails","class":"OCA\\Activity\\MailQueueHandler","type":"->"},{"file":"/var/www/nextcloud/lib/private/BackgroundJob/Job.php","line":54,"function":"run","class":"OCA\\Activity\\BackgroundJob\\EmailNotification","type":"->"},{"file":"/var/www/nextcloud/lib/private/BackgroundJob/TimedJob.php","line":60,"function":"execute","class":"OC\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":152,"function":"execute","class":"OC\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/activity/lib/MailQueueHandler.php","Line":329,"message":"Failed creating activity email for user \"{user}\"","exception":[],"CustomMessage":"Failed creating activity email for user \"User123\""},"id":"658030c341f63"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'REDACTED',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' =>
  array (
    0 => 'REDACTED.domain.name',
    1 => 'REDACTED.domain.name',
    2 => 'REDACTED.ip.address',
  ),
  'trusted_proxies' =>
  array (
    0 => 'REDACTED.ip.address',
  ),
  'datadirectory' => '/var/www/nextcloud-data',
  'overwriteprotocol' => 'https',
  'htaccess.RewriteBase' => '/',
  'dbtype' => 'mysql',
  'version' => '28.0.0.11',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'ncuser',
  'dbpassword' => 'REDACTED',
  'filelocking.enabled' => true,
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory',
  'mail_smtpmode' => 'smtp',
  'mail_from_address' => 'no-reply',
  'mail_domain' => 'REDACTED.domain.name',
  'mail_smtphost' => 'REDACTED.domain.name',
  'mail_smtpport' => '587',
  'default_language' => 'en',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'skeletondirectory' => '',
  'auth.bruteforce.protection.enabled' => false,
  'updater.release.channel' => 'stable',
  'overwrite.cli.url' => 'REDACTED.domain.name',
  'trashbin_retention_obligation' => 'auto',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => array(
          'host' => 'localhost',
          'port' => 6379,
          'timeout' => 0.0,
  ),
  'simpleSignUpLink.shown' => false,
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'auth.webauthn.enabled' => false,
  'mysql.utf8mb4' => true,
);

The timezone is a user value provided I think mostly by their browser at login. You can check it like this:

occ user:setting user123

You can manually override it like this:

occ user:setting user123 core timezone "America/New_York"

But I don’t know offhand under what conditions that will be overridden. There’s a related issue open, but hasn’t seen any traffic in awhile: Don't fail with invalid timezones · Issue #676 · nextcloud/activity · GitHub

1 Like

Hey @jtr, thank you very much for your reply, this fixed the issue!

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.