Email sending unavailable after Nextcloud update
When updating Nextcloud, you may encounter issues with email functionality, such as being unable to send notifications or test emails. This article provides steps to troubleshoot SMTP-related issues in Nextcloud.
Enable or Disable SMTP debug mode
Before making changes to the logging settings, you can check the current log level using the following command:
Via occ command line:
php occ config:system:get loglevel
Or by inspecting config.php:
'loglevel' => ?,
Please note the current log level so you can restore it after you're done troubleshooting.
To enable SMTP debugging in Nextcloud
Via occ command line:
php occ config:system:set --type boolean --value true mail_smtpdebug
php occ config:system:set --type integer --value 0 loglevel
Or by editing config.php:
'mail_smtpdebug' => true,
'loglevel' => 0,
To disable SMTP debugging in Nextcloud
When disabling debug mode, replace "2" with the log level you obtained in the previous step.
Via occ command line:
php occ config:system:set --type boolean --value false mail_smtpdebug
php occ config:system:set --type integer --value 2 loglevel
Or by editing config.php:
'mail_smtpdebug' => false,
'loglevel' => 2,
Send test email
- Login as administrator
- Go to Administration Settings
- Navigate Basic settings
- Click "Send email"
- Check the log file for entries with "Sending mail to"
Common issues
Unable to connect with STARTTLS: stream_socket_enable_crypto(): Peer certificate CN= did not match expected CN=
This error indicates that Nextcloud attempted a TLS connection to your SMTP server, but the server’s certificate does not match the specified domain. This can occur if the SMTP connection is configured to use an IP address rather than a hostname.
Solutions:
Option 1: Use a server address name covered by the SSL certificate.
Option 2: Turn peer verification off for the SMTP connection.
Subscriber exclusive content
A Nextcloud Enterprise Subscription provides unlimited access to our knowledge base articles and direct access to Nextcloud engineers.