Configure email server AxiosError: Request failed with status code 400

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.4
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 24.04
  • Web server and version (e.g, Apache 2.4.25):
    • Apache latest
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • Sophia UTM
  • PHP version (e.g, 8.3):
    • 8.3.6
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • Since the begining
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Ubuntu + install php nextcloud files
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

Trying to configure the emails to receive the notifications

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

Enter all informations about mail server
‘mail_smtpmode’ => ‘smtp’,
‘mail_smtphost’ => ‘mailserver.mydomain.com’,
‘mail_from_address’ => ‘service’,
‘mail_domain’ => ‘mydomain.com’,
‘mail_smtptimeout’ => 30,
‘mail_smtpdebug’ => true,
‘mail_smtpport’ => ‘465’,
‘mail_sendmailmode’ => ‘pipe’,
‘mail_smtpauth’ => true,
‘mail_smtpname’ => ‘mailbox_login’,
‘mail_smtppassword’ => ‘mailbox_password’,

Log entries

Where do I find them in Netxcloud ?
Nextcloud ip is 192.168.10.17

In the mail server I get these logs :slight_smile:

11/05/2025 16:56:38 info disconnect from unknown[192.168.10.17] commands=0/0
11/05/2025 16:56:38 info lost connection after CONNECT from unknown[192.168.10.17]
11/05/2025 16:56:38 info Anonymous TLS connection established from unknown[192.168.10.17]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256
11/05/2025 16:56:38 info TLS SNI MyServer.mydomain.com from unknown[192.168.10.17] not matched, using default chain
11/05/2025 16:56:38 info connect from unknown[192.168.10.17]

Other servers are sending emails without problem.

Nextcloud

Nothing in the logs

Thanks

I’m very glad that I’m not the only one running into a problem here.

I’ll say that I’ve had more trouble with this one item.

I’m not posting “to solve” or to double down on the “me too” but in an effort to increase the conversation and information exchange. I’m going to continue working on troubleshooting this problem.

I’m running the NC-AIO via docker on an Ubuntu system. I had run it before as a test/proof and now I’m doing the “real installation” and I’ve snagged the same problem as others but I can’t seem to even cause a change in the behavior which irks me.

So, first, my feedback and then my config information.


Configuring NC email

Experiencing the error AxiosError: Request failed with status code 400 during configuration of NC 31.0.6


graph TB;
	A((Email<br>Configuration<br>Options)) ;

	1{{Option #1}} ; 
	B1(["<b>Send mode</b><br><i>SMTP</i>"]) ;
	C1a(["<b>Encryption</b><br><i>None/STARTTLS</i>"]) ;
	C1b(["<b>Encryption</b><br><i>SSL</i>"]) ;
	D1(["<b>Sendmail mode</b><br><i>Blank</i>"]) ;
	E1(["<b>From Address</b><br><i>myreturnaddr</i>"]) ;
	F1(["<b>Server Address</b><br><i>servername.domain.edu:25</i>"]) ;
	G1(["<b>Authentication required</b><br><i>Unchecked</i>"]) ;

	A==>1 ; 1==>B1==Path #1==>C1a==>D1==>E1==>F1==>G1==>zza ;

	2{{Option #2}} ;
	B2(["<b>Send mode</b><br><i>Sendmail</i>"]) ;

	A==>2 ; 2==>B1 ;

	B1==Path #2==>C1b==>D1 ;

	3{{Option #3}} ;
	A==>3 ; 3==> B2 ;

	C2(["<b>Encryption</b><br><i>N/A</i>"]) ;
	D2a(["<b>Sendmail mode</b><br><i>smtp (-bs)</i>"]) ;

	B2==>C2==Path #3==>D2a==>zza ;

	4{{Option #4}} ;
	A==>4 ; 4==> B2 ;

	D2b(["<b>Sendmail mode</b><br><i>pipe (-t -i)</i>"]) ;

	C2==Path #4==>D2b==>zza ;

	zza{{"<b>Send&nbsp;email</b>&nbsp;Test&nbsp;button"}};
	zza==>zzb ;
	zzb>"<i>AxiosError:&nbsp;Request&nbsp;failed&nbsp;with&nbsp;status&nbsp;code&nbsp;400</i>"] ;

	style zzb fill:#f9f,stroke:#333,stroke-width:4px

What I’d put on a wish list…

A test for each layer of the process:

  1. Unit test for email from container to target, localhost, smarthost, etc.
    The equivalent of
    telnet {target_host} {target_port}
    This test, maybe a script if needed, would send a test email to a specific target to show that from just below the form, all the other layers work.
  2. Unit test showing the output of the form when the “Send email” button is triggered.
  3. A means for RESETTING the configuration of this section to permit repeated testing.
  4. An explanation of what a “400” status code really is.
    (Any any other error codes that can be generated.)

My configurations:

OCC config:list system

{
    "system": {
        "one-click-instance": true,
        "one-click-instance.user-limit": 100,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "check_data_directory_permissions": false,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "overwritehost": "csg-cloud.DOMAIN.US",
        "overwriteprotocol": "https",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "csg-cloud.DOMAIN.US"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "31.0.6.2",
        "overwrite.cli.url": "https:\/\/csg-cloud.DOMAIN.US\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "updatechecker": false,
        "default_phone_region": "US",
        "loglevel": 2,
        "log_type": "file",
        "logfile": "\/var\/www\/html\/data\/nextcloud.log",
        "log_rotate_size": 10485760,
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "preview_max_x": 2048,
        "preview_max_y": 2048,
        "jpeg_quality": 60,
        "enabledPreviewProviders": {
            "1": "OC\\Preview\\Image",
            "2": "OC\\Preview\\MarkDown",
            "3": "OC\\Preview\\MP3",
            "4": "OC\\Preview\\TXT",
            "5": "OC\\Preview\\OpenDocument",
            "6": "OC\\Preview\\Movie",
            "7": "OC\\Preview\\Krita",
            "0": "OC\\Preview\\Imaginary",
            "23": "OC\\Preview\\ImaginaryPDF"
        },
        "enable_previews": true,
        "upgrade.disable-web": true,
        "mail_smtpmode": "sendmail",
        "mail_smtpdebug": "false",
        "trashbin_retention_obligation": "auto, 30",
        "versions_retention_obligation": "auto, 30",
        "activity_expire_days": 30,
        "simpleSignUpLink.shown": false,
        "share_folder": "\/Shared",
        "one-click-instance.link": "https:\/\/nextcloud.com\/all-in-one\/",
        "upgrade.cli-upgrade-link": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/2726",
        "updatedirectory": "\/nc-updater",
        "maintenance_window_start": 100,
        "allow_local_remote_servers": true,
        "davstorage.request_timeout": 3600,
        "documentation_url.server_logs": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/5425",
        "htaccess.RewriteBase": "\/",
        "dbpersistent": false,
        "auth.bruteforce.protection.enabled": true,
        "ratelimit.protection.enabled": true,
        "files_external_allow_create_new_local": false,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "preview_imaginary_url": "***REMOVED SENSITIVE VALUE***",
        "preview_imaginary_key": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "pipe",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "twofactor_enforced": "true",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [],
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_smtpsecure": "ssl",
        "DOMAIN": "csg-cloud.DOMAIN.US"
    }
}


OCC app:list

Enabled:
  - activity: 4.0.0
  - admin_audit: 1.21.0
  - analytics: 5.6.2
  - bruteforcesettings: 4.0.0
  - calendar: 5.3.4
  - checksum: 1.2.6
  - circles: 31.0.0
  - cloud_federation_api: 1.14.0
  - comments: 1.21.0
  - contacts: 7.1.3
  - contactsinteraction: 1.12.0
  - dashboard: 7.11.0
  - dav: 1.33.0
  - dav_push: 0.0.3
  - deck: 1.15.1
  - drawio: 3.1.0
  - federatedfilesharing: 1.21.0
  - federation: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_external: 1.23.0
  - files_fulltextsearch: 31.0.0
  - files_mindmap: 0.0.33
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_retention: 2.0.1
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - forms: 5.1.1
  - fulltextsearch: 31.0.0
  - fulltextsearch_elasticsearch: 31.0.0
  - groupfolders: 19.1.1
  - htmlviewer: 31.0.0
  - integration_github: 3.2.1
  - integration_gitlab: 3.2.0
  - integration_slack: 2.0.2
  - intros: 1.1.2
  - logcleaner: 1.1.8
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - nextcloud-aio: 0.8.0
  - nextcloud_announcements: 3.0.0
  - notes: 4.12.1
  - notifications: 4.0.0
  - notify_push: 1.1.0
  - oauth2: 1.19.1
  - onlyoffice: 9.9.0
  - password_policy: 3.0.0
  - photos: 4.0.0-dev.1
  - polls: 8.0.4
  - privacy: 3.0.0
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recommendations: 4.0.0
  - registration: 2.7.0
  - related_resources: 2.0.0
  - richdocuments: 8.7.1
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - spreed: 21.1.1
  - support: 3.0.0
  - survey_client: 3.0.0
  - systemtags: 1.21.1
  - tables: 0.9.3
  - tasks: 0.16.1
  - text: 5.0.0
  - theming: 2.6.1
  - theming_customcss: 1.18.0
  - timetracker: 0.0.85
  - twofactor_backupcodes: 1.20.0
  - twofactor_totp: 13.0.0-dev.0
  - updatenotification: 1.21.0
  - user_status: 1.11.0
  - viewer: 4.0.0
  - weather_status: 1.11.0
  - webhook_listeners: 1.2.0
  - whiteboard: 1.1.2
  - workflowengine: 2.13.0
Disabled:
  - app_api: 5.0.2 (installed 5.0.2)
  - cfg_share_links: 7.0.1 (installed 7.0.1)
  - encryption: 2.19.0
  - files_inotify: 0.2.3
  - suspicious_login: 9.0.1
  - twofactor_nextcloud_notification: 5.0.0
  - user_ldap: 1.22.0
  - xwiki: 1.0.0 (installed 1.0.0)

i also have the problem “axios error:request failed with status code 400”
My prerequisites are as follows:

  • I have deployed Nextcloud in an ​​internal network environment​​.
  • My mail server is also ​​independently deployed on the internal network​​.
  • The mail server’s internal domain is ​mail.hz-group.com​.
  • It is configured to ​​mandatorily require username + password authentication for sending emails​​.
  • docker configuration: when i run the nextcloud docker without docker compose.yml,just commands:
    docker run -d \ --name nextcloud \ -p 8080:80 \ -v /nextcloud/data:/var/www/html/data \ -v /nextcloud/config:/var/www/html/config \ -v /nextcloud/apps:/var/www/html/custom_apps \ nextcloud:latest​
  • test the network connection ​telnet mail.hz-group.com 25; ping mail.hz-group.com ​, shows the network connected,220

After logging in as an administrator, I configured the email server in the ​​Admin Settings​​ with the following parameters:

  • ​Protocol​​: SMTP
  • ​SSL/TLS​​: Disabled (since the mail server is configured without SSL)
  • ​Sender Address​​: A valid internal email address (e.g., user@hz-group.com)
  • ​Server Address​​: Internal mail server domain (mail.hz-group.com)
  • ​Port​​: 25 (unencrypted SMTP)
  • Personal Profile:set personal email address in personal profile

However, when sending a test email, I encountered the error:
AxiosError: Request failed with status code 400
Please help me to solve this question

Don’t rely on the test. I spent two days trying to solve this and it turned out the email configuration was 100% working Real emails (user creation, notifications) worked perfectly
I think the “Send email” test button in Nextcloud admin has a bug/issue - it gives a 400 error even when emails are actually being sent

Has anyone managed to resolve this issue? I have been trying for 4 days, but it is still not working and I continue to receive the following error:

AxiosError: Request failed with status code 400

Your assistance would be greatly appreciated