Nextcloud-AIO email test doesn't work

Nextcloud version : 27.1.2.1
Operating system and version: Docker on Unraid
Nextcloud-AIO: Nextcloud Hub 6

I’m having issue setting up the email notification system in Nextcloud-AIO containers after a reinstallation. In particular I want to use a gmail account with an application password specifically generated by my Google Account Management page, but when I click on the “Send email” button to test and verify the email settings it doesn’t work.

The output of my Nextcloud log in Admin > Logging page doesn’t report anything about the email issue. I also enabled the ‘mail_smtpdebug’ => true in my config file and restarted the nextcloud-aio-nextcloud container but nothing changged. I cannot find a log which describe be what is the problem.

In my config.php, which is almost the default, except for the mail_smtpdebug option I added to it, looks like this in the mail configuration part:

  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'myusername',
  'mail_domain' => 'gmail.com',
  'mail_smtphost' => 'smtp.google.com',
  'mail_smtpport' => '465',
  'mail_smtpauth' => 1,
  'mail_smtpdebug' => true,
  'mail_smtpname' => 'myusername@gmail.com',
  'mail_smtppassword' => 'aaaa bbbb cccc dddd',

The last line of output in my nextcloud.log was written yesterday evening and as I reported above it’s not even related to the email settings (keep in mind that I did the email verification test right now, so I should expect some error reported in the log, but it’s not happening)

{
    "app": "core",
    "data": {
        "app": "core",
        "exception": "{\"class\":\"ValueError\",\"message\":\"hash_hkdf(): Argument #2 ($key) cannot be empty\",\"code\":0,\"file\":\"/var/www/html/lib/private/Security/Crypto.php:160\",\"trace\":\"#0 /var/www/html/lib/private/Security/Crypto.php(160): hash_hkdf('sha512', '')\\n#1 /var/www/html/lib/private/Security/Crypto.php(134): OC\\Security\\Crypto->decryptWithoutSecret('17e2f0c78b6e3a2...', '')\\n#2 /var/www/html/lib/private/Security/IdentityProof/Manager.php(128): OC\\Security\\Crypto->decrypt('17e2f0c78b6e3a2...')\\n#3 /var/www/html/lib/private/Security/IdentityProof/Manager.php(146): OC\\Security\\IdentityProof\\Manager->retrieveKey('user-admin')\\n#4 /var/www/html/lib/private/Security/IdentityProof/Signer.php(64): OC\\Security\\IdentityProof\\Manager->getKey(Object(OC\\User\\User))\\n#5 /var/www/html/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php(137): OC\\Security\\IdentityProof\\Signer->sign('lookupserver', Array, Object(OC\\User\\User))\\n#6 /var/www/html/lib/public/BackgroundJob/Job.php(81): OCA\\LookupServerConnector\\BackgroundJobs\\RetryJob->run(Array)\\n#7 /var/www/html/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php(102): OCP\\BackgroundJob\\Job->start(Object(OC\\BackgroundJob\\JobList))\\n#8 /var/www/html/lib/public/BackgroundJob/Job.php(67): OCA\\LookupServerConnector\\BackgroundJobs\\RetryJob->start(Object(OC\\BackgroundJob\\JobList))\\n#9 /var/www/html/cron.php(152): OCP\\BackgroundJob\\Job->execute(Object(OC\\BackgroundJob\\JobList), Object(OC\\Log))\\n#10 {main}\"}"
    },
    "level": 3,
    "message": "Error while running background job (class: OCA\\LookupServerConnector\\BackgroundJobs\\RetryJob, arguments: Array\n(\n    [userId] => admin\n)\n)",
    "method": "",
    "remoteAddr": "",
    "reqId": "YCR3GzpWwLiqxNUApKK5",
    "time": "2023-10-18T21:29:43+00:00",
    "url": "--",
    "user": "--",
    "userAgent": "--",
    "version": "27.1.2.1"
}

so how can I troubleshoot this issue if I don’t have any clue on what’s the problem? Where am I supposed to find the logs related to the email settings? Am I doing something wrong in the email setup?
Thanks in advance

For the log entry, there is already a bug report:

1 Like

Hi, see Email — Nextcloud latest Administration Manual latest documentation

Thanks, it looks like I wasn’t able to see any log message due to the log level. I changed it from 2 to 0 (debug) and I found that the reason is:

stream_socket_client(): Unable to connect to ssl://smtp.google.com:465 (Operation timed out)

so I tried to ping it from the nextcloud-aio-nextcloud container to see if I can resolve the name and reach the server and both works:

aa90fa011400:/var/www/html$ ping smtp.google.com
PING smtp.google.com (142.250.13.26): 56 data bytes
64 bytes from 142.250.13.26: seq=0 ttl=42 time=78.018 ms
64 bytes from 142.250.13.26: seq=1 ttl=42 time=77.992 ms
64 bytes from 142.250.13.26: seq=2 ttl=42 time=77.841 ms
^C
--- smtp.google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss

but when I try to see if the port is reachable, the command reaches a timeout:

aa90fa011400:/var/www/html# busybox-extras telnet smtp.google.com 465
telnet: can't connect to remote host (142.250.13.26): Operation timed out

and I get the same result if I test the port 587.
I’m not behind a firewall actually, so it doesn’t make any sense honestly. Do someone have any idea?