-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Tip
Help move this idea forward
- Use the 👍 reaction to show support for this feature.
- Avoid commenting unless you have relevant information to add; unnecessary comments create noise for subscribers.
- Subscribe to receive notifications about status changes and new comments.
Is your feature request related to a problem? Please describe.
When setting up email sending in the "Basic Settings" (/settings/admin) and section "Email server", the "Send email" test can fail with the error:
AxiosError: Request failed with status code 400
This is the result of the POST request to /settings/admin/mailtest with a 400 (HTTP Bad Request) response, due to the current account not having set an email address yet.
The reason for the error is not shown, nor does it get logged in the Nextcloud server logs.
Only checking the response of the failed request in the browser developer console network tab, reveals the following:
"You need to set your account email before being able to send test emails. Go to https://cloud.example.com/settings/user for that."
Setting an email in the "Personal info" (/settings/user) menu, resolves the issue.
Describe the solution you'd like
I would like the issue to be easier to debug, this means making the issue more transparent to the user.
- Show the error description in the frontend, instead of only the XHR library error.
- Log the error on the server too, so it appears in the Nextcloud log.
- Possibly, change the HTTP code to something more fitting, as the request itself is not "Bad", but a requirement is not fulfilled.
Describe alternatives you've considered
Add more hints in docs and the web interface to indicate the requirement:
- In the email configuration docs: https://docs.nextcloud.com/server/32/admin_manual/configuration_server/email_configuration.html
- In "Basic Settings" (
/settings/admin) next to the "Send email" test button, as a tooltip, etc.
Additional context
This specific error is discussed in multiple places. As it seems like the same error can also be caused by other things, the advice is mixed and not everybody finds a solution.
- https://www.reddit.com/r/NextCloud/comments/1jind7l/comment/mjh3ari/
- https://help.nextcloud.com/t/axioserror-request-failed-with-status-code-400/217651
- [Bug]: Error setting up email server: AxiosError: Request failed with status code 400 #50845
2 comments are pointing out the same error messages as this issue:
Source code:
- Server: https://github.com/nextcloud/server/blob/master/apps/settings/lib/Controller/MailSettingsController.php#L153
- Client: https://github.com/nextcloud/server/blob/master/apps/settings/src/admin.js#L67
Docs:
If necessary, the Axios docs for custom errors: https://axios-http.com/docs/handling_errors