AxiosError: Request failed with status code 400

I was receiving this error message while trying to use a 3rd party mailer service like mailgun/mailersend and resorted to using Postfix smtp relaying for a temporary fix.

Just to be clear my config.php looked like this before the changes.

  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => 'smtp.mydomain.com',
  'mail_smtpauth' => 1,
  'mail_smtpport' => '587',
  'mail_from_address' => 'noreply',
  'mail_domain' => 'mydomain.com',

After reading through the documentation and scrubbing my config.php I found the solution was to add the following to my config.

'mail_smtptimeout' => 30,
  'mail_smtpname'     => 'user@smtphost.com',
  'mail_smtppassword' => 'supersecretpassword',

I’ll post the system details for fun.

Nextcloud
Nextcloud Hub 9 (30.0.6)

PHP
8.3.17

OS
Ubuntu 22.04.5 LTS x86_64
Linux 5.15.0-131-generic x86_64

So to clarify I resolved my issue by manually adding the smtp credentials to the configuration file (yes I know its a security risk but this isn’t a production host). If the Administration Portal → Basic Settings does any sort of credential saving it wasn’t properly for me (I ensured my config.php could be written by NextCloud). I suppose this should be looked at further by someone who knows that area of the NextCloud source and maybe we can even add something to the Basic Settings page to allow for more of these configuration parameters found in the documentation.

I hope this helps someone as much as it did me.

https://docs.nextcloud.com/server/30/admin_manual/configuration_server/email_configuration.html