# Unable to send emails from nextcloud - AxiosError 400

**URL:** <https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392>\
**Category:** ℹ️ Support\
**Tags:** mac, nc29\
**Created:** [March 8, 2025, 7:56am UTC](https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392 "2025-03-08T07:56:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![TWilliams](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twilliams/32/69844_2.png) [@TWilliams](https://help.nextcloud.com/u/TWilliams)\
**Post date:** [March 8, 2025, 7:56am UTC](https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392/1 "2025-03-08T07:56:49Z")

</div>

[details=“Support intro”]

Hi there – I’m running Nextcloud 29.0.12. My instance of Nextcloud is not successfully sending test emails.

I have tested with two different known-good mail servers and configurations and have just not had any luck. I’d welcome any assistance.

Everything else seems to be running happily.

### The Basics

- Nextcloud Server version _(e.g., 29.x.x)_:
  - `29.0.12 (Docker), and 30.0.6 (Docker)`

- Operating system and version _(e.g., Ubuntu 24.04)_:
  - `Ubuntu 24.04.1`

- Web server and version _(e.g, Apache 2.4.25)_:
  - `Whatever's in the docker container`

- Reverse proxy and version \_(e.g. nginx 1.27.2)
  - `nginx proxy manager`

- Are you using CloudfIare, mod\_security, or similar? _(Yes / No)_
  - `No`

### Steps to replicate it (hint: details matter!):

1. Configure config.php (see relevant settings below)
2. Log into Nextcloud as admin.
3. Verify that there’s an email address specified for the admin user by checking Personal Settings → Personal Info → Email.
4. Go to Administration Settings → Basic Settings - Email Server
5. Configure server settings
6. Click “Send Email”.
7. Speak expletive of choice.

### Log entries

```auto
{"reqId":"LP9xrWR43DFUecH03fnN","level":0,"time":"2025-03-08T01:33:36+00:00","remoteAddr":"10.123.45.01","user":"admin","app":"no app in context","method":"POST","url":"/settings/admin/mailtest","message":"Email transport \"Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport\" starting","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36","version":"29.0.12.2","data":[]}>

{"reqId":"LP9xrWR43DFUecH03fnN","level":0,"time":"2025-03-08T01:33:36+00:00","remoteAddr":"10.123.45.01","user":"admin","app":"core","method":"POST","url":"/settings/admin/mailtest","message":"Sending mail to \"Array\n(\n [admin@mycompany.com] => admin\n)\n\" with subject \"Email setting test\" failed"}}

{"reqId":"LP9xrWR43DFUecH03fnN","level":0,"time":"2025-03-08T01:33:36+00:00","remoteAddr":"10.123.45.01","user":"admin","app":"core","method":"POST","url":"/settings/admin/mailtest","message":"","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36","version":"29.0.12.2","data":{"app":"core"}}

```

### Configuration

```auto
<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '[REDACTED]',
    'password' => '[REDACTED]',
    'port' => 6379,
  ),
  'trusted_proxies' => 
  array (
    0 => '172.24.0.0/16',
    1 => '10.0.0.0/8',
    2 => '127.0.0.1',
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => 'smtp.mywebhost.com',
  'mail_smtpport' => '25',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'NoReply',
  'mail_domain' => 'mycompany.com',
  'mail_sendmailmode' => 'smtp',
  'mail_smtptimeout' => 30,
  'mail_smtpauth' => true,
  'mail_smtpname' => 'testuser@mycompany.com',
  'mail_smtppassword' => '[REDACTED]',
  'passwordsalt' => '[REDACTED]',
  'secret' => '[REDACTED]',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '127.0.0.1',
    2 => '10.123.45.67:8004',
    3 => 'myserver.mycompany.com',
  ),
  'default_locale' => 'en_US',
  'default_language' => 'en',
  'default_phone_region' => 'US',
  'auth.webauthn.enabled' => false,
  'maintenance_window_start' => 1,
  'remember_login_cookie_lifetime' => 0,
  'session_lifetime' => 14400,
  'session_keepalive' => true,
  'session_relaxed_expiry' => false,
  'auto_logout' => true,
  'allow_user_to_change_display_name' => false,
  'datadirectory' => '/var/www/html/data',
  'tempdirectory' => '/tmp',
  'dbtype' => 'mysql',
  'dbname' => '[REDACTED]',
  'dbhost' => '[REDACTED]:[REDACTED]',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '[REDACTED]',
  'installed' => true,
  'instanceid' => '[REDACTED]',
  'maintenance' => false,
  'loglevel' => 0,
  'mail_smtpdebug' => 'true',
  'theme' => '',
  'version' => '29.0.12.2',
  'overwritehost' => 'myserver.mycompany.com',
  'overwriteprotocol' => 'https',
  'overwrite.cli.url' => 'https://myserver.mycompany.com',
  'trashbin_retention_obligation' => 'auto, 30',
  'mail_smtpsecure' => 'tls',
);

```

---

<div class="post-metadata">

**Author:** ![Sanook](https://help.nextcloud.com/user_avatar/help.nextcloud.com/sanook/32/13847_2.png) [@Sanook](https://help.nextcloud.com/u/Sanook)\
**Post date:** [March 8, 2025, 9:10am UTC](https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392/2 "2025-03-08T09:10:51Z")

</div>

> [@TWilliams](#):
>
> ‘mail\_smtphost’ =\> ‘[smtp.mywebhost.com](http://smtp.mywebhost.com)’, ‘mail\_smtpport’ =\> ‘25’

does a

`telnet smtp.mywebhost.com 25`

from your Nextclound instance work?

---

<div class="post-metadata">

**Author:** ![TWilliams](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twilliams/32/69844_2.png) [@TWilliams](https://help.nextcloud.com/u/TWilliams)\
**Post date:** [March 8, 2025, 9:18am UTC](https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392/3 "2025-03-08T09:18:15Z")

</div>

Yes it does, on both the host and the Nextcloud docker container (after temporarily installing a telnet client onto it, that is).

---

<div class="post-metadata">

**Author:** ![Sanook](https://help.nextcloud.com/user_avatar/help.nextcloud.com/sanook/32/13847_2.png) [@Sanook](https://help.nextcloud.com/u/Sanook)\
**Post date:** [March 8, 2025, 9:22am UTC](https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392/4 "2025-03-08T09:22:39Z")

</div>

Maybe you have to use port 587 or 465?

What does the email provider say?

---

<div class="post-metadata">

**Author:** ![TWilliams](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twilliams/32/69844_2.png) [@TWilliams](https://help.nextcloud.com/u/TWilliams)\
**Post date:** [March 8, 2025, 9:30am UTC](https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392/5 "2025-03-08T09:30:06Z")

</div>

I did use known-good settings that I’ve used on multiple other devices. but for the sake of testing I did also try with ports 587 and 465, as well as with None/STARTTLS and SSL modes, and I also tried with a different email provider altogether. No joy.

All I get is “AxiosError: Request failed with status code 400”.

For the sake of further testing, I put Nextcloud in “loglevel = 0” mode and also set “mail\_smtpdebug = true”. What I got in the logs was what I shown in my initial post.

I’ve also updated my Nextcloud instance to 30.0.6. Problem persists.

---

<div class="post-metadata">

**Author:** ![TWilliams](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twilliams/32/69844_2.png) [@TWilliams](https://help.nextcloud.com/u/TWilliams)\
**Post date:** [March 8, 2025, 12:18pm UTC](https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392/7 "2025-03-08T12:18:43Z")

</div>

> [@Sanook](#):
>
> For example:
> 
> `openssl s_client -connect smtp.mywebhost.com:587 -starttls smtp`
> 
> Is there anything unusual in the nextcloud.log file?

Running that presented nothing in the nextcloud.log file whatsoever. And that’s even at “loglevel = 0”.

Just for laughs, I followed your suggestion of asking ChatGPT. It offered the obvious suggestions, such as checking the firewall, checking SMTP authentication method, checking the SMTP ports, and making sure the mail provider hasn’t ban-listed the IP. All of which I checked exhaustively before posting here.

---

<div class="post-metadata">

**Author:** ![TWilliams](https://help.nextcloud.com/user_avatar/help.nextcloud.com/twilliams/32/69844_2.png) [@TWilliams](https://help.nextcloud.com/u/TWilliams)\
**Post date:** [March 9, 2025, 3:12am UTC](https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392/8 "2025-03-09T03:12:21Z")

</div>

Okay. I’ve solved the problem. Here’s how I did so:

1 - I killed my Nextcloud docker container  
2 - I originally had email variables configured in my docker-compose.yml. I’ve removed them all.  
3 - I re-deployed my Nextcloud docker instance.  
4 - I re-added my mail settings via the web interface.

All now appears to be working.

TL;DR lesson: If you’re specifying your email settings via your docker-compose.yml, you’re bound to run into problems, so don’t do that.

---

<div class="post-metadata">

**Author:** ![system](https://help.nextcloud.com/user_avatar/help.nextcloud.com/system/32/29333_2.png) [@system](https://help.nextcloud.com/u/system)\
**Post date:** [March 17, 2025, 3:12am UTC](https://help.nextcloud.com/t/unable-to-send-emails-from-nextcloud-axioserror-400/219392/9 "2025-03-17T03:12:23Z")

</div>

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.
