OUTLOOK.COM - AxiosError: Request failed with status code 400

Hi everyone, I’m trying to configure an email address that Nextcloud can use to send notifications, but I’m running into a problem.

I’ve filled in all the required fields in the email settings UI (screenshot attached), but when I try to send a test email, I receive the following error:

AxiosError: Request failed with status code 400

To rule out network or connectivity issues, I ran a few tests via CLI on the Nextcloud server. Here are some details:

root@nextcloud-srv-1 …/nextcloud/data# cat /etc/os-release
PRETTY_NAME=“Debian GNU/Linux 12 (bookworm)”
NAME=“Debian GNU/Linux”
VERSION_ID=“12”
VERSION=“12 (bookworm)”
VERSION_CODENAME=bookworm
ID=debian

root@nextcloud-srv-1 …/nextcloud/data# openssl s_client -starttls smtp -connect smtp-mail.outlook.com:587 -crlf -quiet
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, CN = DigiCert Cloud Services CA-1
verify return:1
depth=0 C = US, ST = Washington, L = Redmond, O = Microsoft Corporation, CN = outlook.com
verify return:1
250 SMTPUTF8

^C
root@nextcloud-srv-1 …/nextcloud/data#

So the Outlook SMTP server is reachable and responds correctly to STARTTLS.

Has anyone encountered this AxiosError 400 issue before when configuring email in Nextcloud? Any ideas on how to troubleshoot or resolve it?

My NextCloud version: Nextcloud Hub 10 (31.0.9)

Maybe the issue is the OAuth2 authentication method required by Microsoft .. I read that NextCloud doesn’t support it yet. What do you think guys? Are there other solutions? Maybe I can change provider ..

Yeah, I think the issue is the OAuth2 authentication method required by Microsoft not supported by NextCloud. I just switched to Google and with GMAIL it worked, but keep in mind that you have to create an App password as described here by Google documentation:

Sign in with app passwords - Google Account Help

You may want to consider utilizing an ESP’s SMTP services rather than the SMTP services intended to be used with standalone email client apps.

The OAuth 2.0 trend is for the latter.

App passwords are discouraged by Google (but still supported at the moment if you enable 2FA) and completely deprecated by Microsoft. Also app passwords are revoked when your main password is changed.

The other thing using an ESP avoids is volume limits, policy violation issues, etc.

ESPs tend to use long strong API keys for the SMTP “username/password” on the SMTP side And know how to support web apps because that’s their business. As a result, ESPs are much more likely to be compatible with web apps like Nextcloud Server.

For small volumes many ESPs have free levels so there’s really no downside either.

I’ve had many years of excellent results with the ESP Mailgun myself (in my home/SMB and with some low volume clients), but that’s just anecdotal. There are many well established ESPs. Others that I’ve also used with success are AWS SES (more enterprise-y) and Twilio Sendgrid.