Mail App - Unable to Send Email - Where can I look to have a useful error message?

Nextcloud version (eg, 20.0.5): 24.0.4
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.52
PHP version (eg, 7.4): 8.1.2

The issue you are facing:
I have an email domain, let’s say it’s @myemail.com (not my real domain name).
I have configured an account of this email (admin@myemail.com) for sending emails for resetting password (as described here: Email — Nextcloud latest Administration Manual latest documentation). All seems fine, mails are sent.
I have installed the app email and configured the account admin@myemail.com. I can read all emails so IMAP is working. However I am unable to send an email. Each time I try, I have a notification saying that the message is sent followed by a notification error “Message could not be sent”.
If I try with other accounts of the same domain, I have the same behavior.
If I try with another domain, it works.

So it seems there is something specific to @myemail.com. However, the reset passwords emails that use the same domain are working well.
I tried to activate some logs by following the procedure given in the chapter “logging” of this url: mail/admin.md at main · nextcloud/mail · GitHub. I have lot of logs about imap but nothing about smtp. I don’t event have a file data/horde_smtp.log.
I have also followed the procedures " Database insert problems on MySQL" and " Timeout and other connectivity issues" because I have no idea. The first one is ok. For the openssl test, here are the results:

Collecting connection statistics for 30 seconds
[lot of * skipped]

2100 connections in 11.31s; 185.68 connections/user sec, bytes read 0
2100 connections in 31 real seconds, 0 bytes read per connection

Now timing with session id reuse.
starting
[lot of * and r skipped]ERROR

I have also tried to " Use php-mail for sending mail" but nothing has changed.
What can I do now to continue my investigation ?

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

Steps to replicate it:

  1. Open the app mail
  2. Configure any account of the domain @myemail.com
  3. Send an email

The output of your Nextcloud log in Admin > Logging:

Nothing about SMTP. Lot of errors about IMAP but timestamps are not correlated with my tests.

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

$CONFIG = array (
  'passwordsalt' => 'REMOVED',
  'secret' => 'REMOVED',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'domain removed',
    2 => 'ip removed',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '24.0.4.1',
  'overwrite.cli.url' => 'https://domain removed',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'removed',
  'dbpassword' => 'removed',
  'installed' => true,
  'instanceid' => 'removed',
  'htaccess.RewriteBase' => '/',
  'debug' => false,
  'loglevel' => 2,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'removed',
  'mail_domain' => 'removed',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'removed',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'removed',
  'mail_smtppassword' => 'removed',
  'maintenance' => false,
  'app.mail.transport' => 'php-mail'
);

The output of your Apache/nginx/system log in /var/log/____:
I don’t see any related message. As there are many lines and I’m not sure how to find all personal/sensitive information I prefer not share it for now.

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.
I don’t see any related message. As there are many lines and I’m not sure how to find all personal/sensitive information I prefer not share it for now.

You’re sure all your SMTP settings are correct? And no problem with the mail server?

That sounds like your mail server has a problem sending mail to other domains. Is that the case?

If you use unencrypted SMTP, you can use a packet capture on the Nextcloud server to read the SMTP conversation and see what’s going on.

Hi KarlF12,

Thank you for your reply.

You’re sure all your SMTP settings are correct? And no problem with the mail server?

Yes. I have checked several times the SMTP settings. I have tried with multiple accounts. The mail server is working fine. I use it everyday with gmail and thunderbird. So far, I have an issue only with the app Mail in Nextcloud. Even the reset password feature of Nextcloud is working.

That sounds like your mail server has a problem sending mail to other domains. Is that the case?

I think the mail server is not reached at all by NextCloud Mail.

If you use unencrypted SMTP, you can use a packet capture on the Nextcloud server to read the SMTP conversation and see what’s going on.

For now I use encrypted SMTP. I will create a dumb account and try your suggestion later in the day.

Thank again for your help!

Hi,

I have tested without encryption. The mails are sent :). I guess I have a certificate issue, I will investigate that.
Thank you very much!