Docker with s3 primary storage can't send emails

Nextcloud version (eg, 20.0.5): 27.0.0
Operating system and version (eg, Ubuntu 20.04): Fedora 38
Apache or nginx version (eg, Apache 2.4.25): apache with nginx reverse proxy
PHP version (eg, 7.4): replace me

The issue you are facing:
I was able to successfully install with mariadb and docker compose. Once I try to add s3 as primary storage it will no longer send emails. Docker logs show a 400 error and setting the smptdebug to true doesn’t give additional details.

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

Steps to replicate it:

  1. Install with docker compose:
version: '3'

services:
  db:
    image: mariadb:10.6
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    restart: unless-stopped
    volumes:
      - db:/var/lib/mysql:Z
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MARIADB_AUTO_UPGRADE=1
      - MARIADB_DISABLE_UPGRADE_BACKUP=1
    env_file:
      - db.env

  redis:
    image: redis:alpine
    restart: unless-stopped

  app:
    image: nextcloud:27.0.0
    restart: unless-stopped
    volumes:
      - nextcloud:/var/www/html:z
    environment:
      - VIRTUAL_HOST=url
      - LETSENCRYPT_HOST=url
      - LETSENCRYPT_EMAIL=email
      - MYSQL_HOST=db
      - REDIS_HOST=redis
    env_file:
      - db.env
    depends_on:
      - db
      - redis
    networks:
      - proxy-tier
      - default

  cron:
    image: nextcloud:27.0.0
    restart: unless-stopped
    volumes:
      - nextcloud:/var/www/html:z
    entrypoint: /cron.sh
    depends_on:
      - db
      - redis

  proxy:
    build: ./proxy
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
    labels:
      com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
    volumes:
      - certs:/etc/nginx/certs:z,ro
      - vhost.d:/etc/nginx/vhost.d:z
      - html:/usr/share/nginx/html:z
      - /var/run/docker.sock:/tmp/docker.sock:z,ro
    networks:
      - proxy-tier

  letsencrypt-companion:
    image: nginxproxy/acme-companion
    restart: unless-stopped
    volumes:
      - certs:/etc/nginx/certs:z
      - acme:/etc/acme.sh:z
      - vhost.d:/etc/nginx/vhost.d:z
      - html:/usr/share/nginx/html:z
      - /var/run/docker.sock:/var/run/docker.sock:z,ro
    networks:
      - proxy-tier
    depends_on:
      - proxy

# self signed
#  omgwtfssl:
#    image: paulczar/omgwtfssl
#    restart: "no"
#    volumes:
#      - certs:/certs
#    environment:
#      - SSL_SUBJECT=servhostname.local
#      - CA_SUBJECT=my@example.com
#      - SSL_KEY=/certs/servhostname.local.key
#      - SSL_CSR=/certs/servhostname.local.csr
#      - SSL_CERT=/certs/servhostname.local.crt
#    networks:
#      - proxy-tier

volumes:
  db:
  nextcloud:
  certs:
  acme:
  vhost.d:
  html:

networks:
  proxy-tier:
  1. Using this db.env:
MYSQL_PASSWORD=password
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
OBJECTSTORE_S3_HOST=us-east-1.linodeobjects.com
OBJECTSTORE_S3_BUCKET=name
OBJECTSTORE_S3_KEY=key
OBJECTSTORE_S3_SECRET=secret
SMTP_HOST=in-v3.mailjet.com
SMTP_NAME=name
SMTP_PASSWORD=password
MAIL_DOMAIN=url
  1. Install all recommended apps. Once able to log in, see that there are errors at admin>overview.
  2. Update config.php to allow trusted proxies, set default phone, etc.
  3. See that the only thing left is to send a test email. Sending an email times out with the following error: A problem occurred while sending the email. Please revise your settings. (Error: Email could not be sent. Check your mail server log)
  4. Running docker logs a33af | grep “mail” gives the following output: 73.214.8.38 - - [28/Jul/2023:14:14:57 +0000] “POST /settings/admin/mailtest HTTP/1.1” 400 910 “-” “Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0”

The output of your Nextcloud log in Admin > Logging:

Error	PHP	Optional parameter $trustedServers declared before required parameter $groupManager is implicitly treated as a required parameter at /var/www/html/apps/dav/lib/CardDAV/SystemAddressbook.php#60	
2023-07-28T09:06:30-0400
Warning	no app in context	Tried to create an object store folder that already exists: 	
2023-07-28T08:57:05-0400
Error	ocs_api	Failed addUser attempt: User already exists.	
2023-07-28T08:56:56-0400
Error	index	OCP\Files\NotPermittedException: Could not create folder "/appdata_oc750p1g5s6j/theming/global"	
2023-07-28T08:38:31-0400
Warning	no app in context	Tried to create an object store folder that already exists: appdata_oc750p1g5s6j/theming/global	
2023-07-28T08:38:31-0400
Warning	no app in context	Tried to create an object store folder that already exists: 	
2023-07-28T08:38:16-0400

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'redis',
    'password' => '',
    'port' => 6379,
  ),
  'objectstore' => 
  array (
    'class' => '\\OC\\Files\\ObjectStore\\S3',
    'arguments' => 
    array (
      'bucket' => 'bucket name',
      'region' => '',
      'hostname' => 'us-east-1.linodeobjects.com',
      'port' => '',
      'objectPrefix' => 'urn:oid:',
      'autocreate' => false,
      'use_ssl' => false,
      'use_path_style' => false,
      'legacy_auth' => false,
      'key' => 'key',
      'secret' => 'secret',
    ),
  ),
  'instanceid' => 'instance',
  'passwordsalt' => 'pass',
  'secret' => 'secret',
  'trusted_domains' => 
  array (
    0 => 'ourveryown.cloud',
  ),
  'trusted_proxies' => 
  array (
    0 => '10.0.0.0/8',
    1 => '172.16.0.0/12',
    2 => '192.168.0.0/16',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '27.0.1.2',
  'overwrite.cli.url' => 'https://url',
  'overwriteprotocol' => 'https',
  'forwarded_for_headers' => 
  array (
    0 => 'HTTP_X_FORWARDED',
    1 => 'HTTP_FORWARDED_FOR',
  ),
  'default_phone_region' => 'us',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'password',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_sendmailmode' => 'smtp',
  'mail_smtpname' => 'name',
  'mail_smtppassword' => 'pass',
  'mail_domain' => 'url',
  'mail_smtpport' => '587',
  'mail_smtphost' => 'in-v3.mailjet.com',
  'mail_smtpdebug' => true,
  'mail_smtpsecure' => 'ssl',
);

The output of your Apache/nginx/system log in /var/log/____:
Nothing in the proxy container and the main container says it isn’t a regular file. Forcing it open doesn’t show anything.

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

https://gist.github.com/Yuki-known/84fd800443f59f4976cc2b67df618ac4

Can you provide the actual entry - timestamped to match - from your nextcloud.log at the time you test the email connection?

  • There are some oddities with your email setup. Since there may be multiple config’s at play (since this is the Docker image there are others besides just config.php used), can you provide the actual output of ./occ config:list system ran from inside your NC container?
  • Both your Primary Storage and Mail configuration is a little weird. It looks a bit like you manually overrode things from your Compose file (because they don’t fully match). And there are entries that are bogus or, in some cases, I suspect not what you intended.
  • Your provided config.php has use_ssl set to false for your object storage which I suspect is wrong (is your storage actually working?).

So, the storage seemed to be working just fine. Objects were getting placed into the s3 bucket and, from what I could tell, were not being stored on the server. I have since got it working by removing the s3 variables from the db.env during creation and adding them into the config.php once the rest of the server was setup. Now, it seems to be working as intended.

1 Like