Unable to send test email - 400 error

Nextcloud version (eg, 20.0.5): 27.1.3
Operating system and version (eg, Ubuntu 20.04): AlmaLinux-8.8
Apache or nginx version (eg, Apache 2.4.25): 2.4.57
PHP version (eg, 7.4): 8.2

The issue you are facing: Unable to send any email at all. Using the “Send email” test button, I’m faced with the following error in chrome/brave inspector:
POST https://cloud.xxxx.com.au/index.php/settings/admin/mailtest 400 (Bad Request)
There’s nothing helpful that shows in logs at all. I’m a bit stuck as to what to check next. I’ve tried utilising SMTP server, local sendmail, etc.
Interestingly, when trying to send a welcome email, there’s a strange error in exim’s log (one of the following two errors will show):
2023-11-15 20:11:36 SMTP call from s6v1.xxxx.com [xxxx] dropped: too many syntax or protocol errors (last command was "?\f?", NULL)
or
2023-11-15 20:12:41 SMTP call from s6v1.xxxx.com [xxxx] dropped: too many syntax or protocol errors (last command was "?\035?\027?\036?\031?\030?#???\026???\027???\r?&?$\004\003\005\003\006\003\b\007\b\b\b \b\004\b", NULL)

Is this the first time you’ve seen this error? (Y/N): Y. Have only just set up nextcloud.

Steps to replicate it:

  1. Installed NextCloud
  2. Tried to set up basic email settings
  3. Clicked “Send email”

The output of your Nextcloud log in Admin > Logging:

empty

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

<?php
$CONFIG = array (
  'instanceid' => 'xxxx',
  'passwordsalt' => 'xxxx',
  'secret' => 'xxxx',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'cloud.xxxx.com.au',
  ),
  'datadirectory' => '/home/xxxx/domains/cloud.xxxx.com.au/public_html/data',
  'dbtype' => 'mysql',
  'version' => '27.1.3.2',
  'overwrite.cli.url' => 'https://cloud.xxxx.com.au',
  'overwritehost' => 'cloud.xxxx.com.au',
  'overwriteprotocol' => 'https',
  'dbname' => 'xxxx_cloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxxx_cloud',
  'dbpassword' => 'xxxx',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'skeletondirectory' => '/home/xxxx/domains/cloud.xxxx.com.au/public_html/data/skeleton',
  'updater.secret' => '$2y$10$cV95HQpMZoNyIszALmApyuyo556wHMMZ/9/nbMTZGYfWLolewsC..',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 3,
  'mail_smtphost' => '127.0.0.1',
  'mail_smtpport' => '25',
  'mail_smtptimeout' => 10,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'cloud',
  'mail_domain' => 'xxxx.com.au',
  "mail_smtpdebug" => true,
  'debug' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

empty

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.

empty

I haven’t finished analyzing your issue yet, but this is what struck me straight away:
If I understand you correctly, you are trying to send your emails via your locally installed exim MTA.
In such cases the mail_smtpmode should be set to ‘sendmail’. mail_sendmailmode defaults to smtp, so not necessary to add to config.

Read → this ←

Much luck,
ernolf

Thanks Ernolf.
I have tried many different configurations, including “sendmail” as you suggested. Still no luck!

Hi @shadowq
Could you solve this? I have exactly the same here.
Besser