Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error setting up email server: AxiosError: Request failed with status code 400 #50845

Open
5 of 8 tasks
glxaa opened this issue Feb 17, 2025 · 12 comments
Open
5 of 8 tasks
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 30-feedback bug feature: emails feature: settings

Comments

@glxaa
Copy link

glxaa commented Feb 17, 2025

⚠️ This issue respects the following points: ⚠️

Bug description

I received an Axios error while setting up my email server, and no matter which email server I change, it always reports an error: AxiosError: Request failed with status code 400。

Image

Regarding this error, I found a similar question to mine on the official forum of NextCloud, but the problem was solved by manually modifying the parameters of the smtp server in the configuration file. I tried the same method, but still received the error message "AxiosError: Request failed with status code 400".
It is worth mentioning that according to the documentation, I enabled debugging of email logs and adjusted the NextCloud log level to 0. When the request fails, I cannot receive any debug logs about emails.

Steps to reproduce

  1. Open the basic settings
  2. Device SMTP Mail Server
  3. Error

Expected behavior

Can correctly set up the SMTP server

Nextcloud Server version

30

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "10.1.1.2:11224"
        ],
        "dbtype": "mysql",
        "version": "30.0.6.2",
        "overwrite.cli.url": "https:\/\/10.1.1.2:11224",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "theme": "",
        "loglevel": 2,
        "maintenance": false,
        "appstoreenabled": true,
        "default_phone_region": "CN",
        "default_language": "zh_CN",
        "default_locale": "zh",
        "enable_previews": true,
        "enabledPreviewProviders": {
            "0": "OC\\Preview\\Imaginary",
            "19": "OC\\Preview\\TXT",
            "1": "OC\\Preview\\MarkDown",
            "2": "OC\\Preview\\OpenDocument",
            "3": "OC\\Preview\\PDF",
            "4": "OC\\Preview\\MSOffice2003",
            "5": "OC\\Preview\\MSOfficeDoc",
            "6": "OC\\Preview\\PDF",
            "7": "OC\\Preview\\Image",
            "8": "OC\\Preview\\Photoshop",
            "9": "OC\\Preview\\TIFF",
            "10": "OC\\Preview\\SVG",
            "11": "OC\\Preview\\Font",
            "12": "OC\\Preview\\MP3",
            "13": "OC\\Preview\\Movie",
            "14": "OC\\Preview\\MKV",
            "15": "OC\\Preview\\MP4",
            "16": "OC\\Preview\\AVI",
            "17": "OC\\Preview\\EMF",
            "18": "OC\\Preview\\Krita",
            "20": "OC\\Preview\\WEBP"
        },
        "preview_imaginary_url": "***REMOVED SENSITIVE VALUE***",
        "preview_format": "webp",
        "app_install_overwrite": [
            "files_markdown"
        ],
        "maintenance_window_start": 1,
        "twofactor_enforced": "true",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [],
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_smtpauth": 1,
        "mail_smtptimeout": 30,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - activity: 3.0.0
  - app_api: 4.0.6
  - bruteforcesettings: 3.0.0
  - circles: 30.0.0
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - contactsinteraction: 1.11.0
  - dashboard: 7.10.0
  - dav: 1.31.1
  - federatedfilesharing: 1.20.0
  - federation: 1.20.0
  - files: 2.2.0
  - files_downloadlimit: 3.0.0
  - files_external: 1.22.0
  - files_pdfviewer: 3.0.0
  - files_reminders: 1.3.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - firstrunwizard: 3.0.0
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - nextcloud_announcements: 2.0.0
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - previewgenerator: 5.8.0
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - recommendations: 3.0.0
  - related_resources: 1.5.0
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - support: 2.0.0
  - survey_client: 2.0.0
  - systemtags: 1.20.0
  - text: 4.1.0
  - theming: 2.6.0
  - twofactor_backupcodes: 1.19.0
  - twofactor_nextcloud_notification: 4.0.0
  - twofactor_totp: 12.0.0-dev
  - updatenotification: 1.20.0
  - user_status: 1.10.0
  - viewer: 3.0.0
  - weather_status: 1.10.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - admin_audit: 1.20.0
  - encryption: 2.18.0
  - suspicious_login: 8.0.0
  - user_ldap: 1.21.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

此错误无日志

Additional info

No response

@glxaa glxaa added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Feb 17, 2025
@glxaa
Copy link
Author

glxaa commented Feb 17, 2025

It should be noted that my Mariadb version is not recommended for V30.0.6. Is this related to it?

Image

@bjo81
Copy link

bjo81 commented Feb 17, 2025

I'm getting the same error on a freshly installed 30.0.6 (with MariaDB 10.11, so maybe that's not related). Unfortunately

"mail_smtpdebug" => true,
"loglevel" => 0,

logs nothing mail related and no SMTP -> get_lines() lines appear.

@dariocigna
Copy link

dariocigna commented Feb 17, 2025

Same error here, and nothing found in log

I tried on different smtp accounts, same error

edit: only the test mail is not working.

other mail are correctly delivered

@bjo81
Copy link

bjo81 commented Feb 17, 2025

As a workaround, set

('core','emailTestSuccessful','1',2,0)

in the oc_appsettings table of your Nextcloud database.

@joshtrichards
Copy link
Member

@LeonTutte
Copy link

LeonTutte commented Feb 17, 2025

Same error here, and nothing found in log

I tried on different smtp accounts, same error

edit: only the test mail is not working.

other mail are correctly delivered

I'm having the same error with a fresh installation via docker and PostgreSQL. All mail, except the test mail, works as expected.
I checked my postgrestables (like @bjo81 suggested) and updated the values accordingly, since the entry existed already.

  1. docker exec -it nextcloud-postgres psql -U nextcloud
  2. SELECT * FROM oc_appconfig WHERE configkey = 'emailTestSuccessful';
  3. UPDATE oc_appconfig SET configvalue = '1' WHERE configkey = 'emailTestSuccessful';

@Mazamazine
Copy link

Mazamazine commented Feb 17, 2025

Same error with a fresh install (30.0.6) on a VM on debian, using Sendmail or SMTP configurations (emails are correctly sent when creating an account tough, only the test fails). The debug mode didn't give any useful information. I only see the 400 in apache logs.

Changing the emailTestSuccessful doesn't work for me: as soon as I try testing the email configuration through the GUI, it's set back to 0. Unless I didn't understand the goal (at least the overview has no warning about this anymore). I also tried a different browser as suggested in another thread with no luck.

@bjo81
Copy link

bjo81 commented Feb 17, 2025

Changing the emailTestSuccessful doesn't work for me: as soon as I try testing the email configuration through the GUI, it's set back to 0. Unless I didn't understand the goal (at least the overview has no warning about this anymore). I also tried a different browser as suggested in another thread with no luck.

Yes, it will reset to 0 if you test again and it fails - but setting it to 1 removes the annoying message that you haven't configured e-mail.

@nano11bravo
Copy link

nano11bravo commented Feb 17, 2025

⚠️ This issue respects the following points: ⚠️

Bug description

I received an Axios error while setting up my email server, and no matter which email server I change, it always reports an error: AxiosError: Request failed with status code 400。

Image

Regarding this error, I found a similar question to mine on the official forum of NextCloud, but the problem was solved by manually modifying the parameters of the smtp server in the configuration file. I tried the same method, but still received the error message "AxiosError: Request failed with status code 400". It is worth mentioning that according to the documentation, I enabled debugging of email logs and adjusted the NextCloud log level to 0. When the request fails, I cannot receive any debug logs about emails.

Steps to reproduce

  1. Open the basic settings
  2. Device SMTP Mail Server
  3. Error

Expected behavior

Can correctly set up the SMTP server

Nextcloud Server version

30

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)[ ] LDAP/ Active Directory[ ] SSO - SAML[ ] Other

Configuration report

{
"system": {
"datadirectory": "REMOVED SENSITIVE VALUE",
"instanceid": "REMOVED SENSITIVE VALUE",
"passwordsalt": "REMOVED SENSITIVE VALUE",
"secret": "REMOVED SENSITIVE VALUE",
"trusted_domains": [
"10.1.1.2:11224"
],
"dbtype": "mysql",
"version": "30.0.6.2",
"overwrite.cli.url": "https://10.1.1.2:11224",
"dbname": "REMOVED SENSITIVE VALUE",
"dbhost": "REMOVED SENSITIVE VALUE",
"dbport": "",
"dbtableprefix": "oc_",
"mysql.utf8mb4": true,
"dbuser": "REMOVED SENSITIVE VALUE",
"dbpassword": "REMOVED SENSITIVE VALUE",
"installed": true,
"memcache.local": "\OC\Memcache\APCu",
"memcache.distributed": "\OC\Memcache\Redis",
"memcache.locking": "\OC\Memcache\Redis",
"redis": {
"host": "REMOVED SENSITIVE VALUE",
"port": 6379,
"password": "REMOVED SENSITIVE VALUE"
},
"theme": "",
"loglevel": 2,
"maintenance": false,
"appstoreenabled": true,
"default_phone_region": "CN",
"default_language": "zh_CN",
"default_locale": "zh",
"enable_previews": true,
"enabledPreviewProviders": {
"0": "OC\Preview\Imaginary",
"19": "OC\Preview\TXT",
"1": "OC\Preview\MarkDown",
"2": "OC\Preview\OpenDocument",
"3": "OC\Preview\PDF",
"4": "OC\Preview\MSOffice2003",
"5": "OC\Preview\MSOfficeDoc",
"6": "OC\Preview\PDF",
"7": "OC\Preview\Image",
"8": "OC\Preview\Photoshop",
"9": "OC\Preview\TIFF",
"10": "OC\Preview\SVG",
"11": "OC\Preview\Font",
"12": "OC\Preview\MP3",
"13": "OC\Preview\Movie",
"14": "OC\Preview\MKV",
"15": "OC\Preview\MP4",
"16": "OC\Preview\AVI",
"17": "OC\Preview\EMF",
"18": "OC\Preview\Krita",
"20": "OC\Preview\WEBP"
},
"preview_imaginary_url": "REMOVED SENSITIVE VALUE",
"preview_format": "webp",
"app_install_overwrite": [
"files_markdown"
],
"maintenance_window_start": 1,
"twofactor_enforced": "true",
"twofactor_enforced_groups": [],
"twofactor_enforced_excluded_groups": [],
"mail_from_address": "REMOVED SENSITIVE VALUE",
"mail_smtpmode": "smtp",
"mail_sendmailmode": "smtp",
"mail_domain": "REMOVED SENSITIVE VALUE",
"mail_smtphost": "REMOVED SENSITIVE VALUE",
"mail_smtpport": "25",
"mail_smtpauth": 1,
"mail_smtptimeout": 30,
"mail_smtpname": "REMOVED SENSITIVE VALUE",
"mail_smtppassword": "REMOVED SENSITIVE VALUE"
}
}

List of activated Apps

Enabled:

  • activity: 3.0.0
  • app_api: 4.0.6
  • bruteforcesettings: 3.0.0
  • circles: 30.0.0
  • cloud_federation_api: 1.13.0
  • comments: 1.20.1
  • contactsinteraction: 1.11.0
  • dashboard: 7.10.0
  • dav: 1.31.1
  • federatedfilesharing: 1.20.0
  • federation: 1.20.0
  • files: 2.2.0
  • files_downloadlimit: 3.0.0
  • files_external: 1.22.0
  • files_pdfviewer: 3.0.0
  • files_reminders: 1.3.0
  • files_sharing: 1.22.0
  • files_trashbin: 1.20.1
  • files_versions: 1.23.0
  • firstrunwizard: 3.0.0
  • logreader: 3.0.0
  • lookup_server_connector: 1.18.0
  • nextcloud_announcements: 2.0.0
  • notifications: 3.0.0
  • oauth2: 1.18.1
  • password_policy: 2.0.0
  • photos: 3.0.2
  • previewgenerator: 5.8.0
  • privacy: 2.0.0
  • provisioning_api: 1.20.0
  • recommendations: 3.0.0
  • related_resources: 1.5.0
  • serverinfo: 2.0.0
  • settings: 1.13.0
  • sharebymail: 1.20.0
  • support: 2.0.0
  • survey_client: 2.0.0
  • systemtags: 1.20.0
  • text: 4.1.0
  • theming: 2.6.0
  • twofactor_backupcodes: 1.19.0
  • twofactor_nextcloud_notification: 4.0.0
  • twofactor_totp: 12.0.0-dev
  • updatenotification: 1.20.0
  • user_status: 1.10.0
  • viewer: 3.0.0
  • weather_status: 1.10.0
  • webhook_listeners: 1.1.0-dev
  • workflowengine: 2.12.0
    Disabled:
  • admin_audit: 1.20.0
  • encryption: 2.18.0
  • suspicious_login: 8.0.0
  • user_ldap: 1.21.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

此错误无日志

Additional info

No response

I noticed that in this config port 25 is specified and not totally sure 163.com fully supports that anymore?

Outgoing Server - SMTP
Server: smtp.163.com
Port: 465
Security: SSL/TLS
Username: Your full email address
Password: Your password

General SMTP port settings for 163.COM
Outgoing (SMTP) Secure - Port: 465 for and Security Type: SSL/TLS (Accept all certificates)
Outgoing (SMTP roaming server) Secure - Port: 587 and Security Type: SSL/TLS (Accept all certificates)
Outgoing (SMTP) - Port: 25 and Security Type: None (Accept all certificates)
Outgoing (SMTP roaming server) Insecure - Port: 587 and Security Type: None (Accept all certificates)

@glxaa
Copy link
Author

glxaa commented Feb 20, 2025

I have solved my question. If the problem occurs, you can try the following methods to solve it:

  1. Manually configure the email server:
'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',
'mail_smtptimeout' => 30,
'mail_smtpname' => ' [email protected] ',
'mail_smtppassword' => 'supersecretpassword',

Note that it is necessary to add the configuration of 'mail_stmtptimeout'=>30.

  1. At this point, if the newly created email server of NextCloud application still reports an Ajax error, the email transmission will fail. The reason is that the 'admin' account has not been configured with * * personal email * *. I speculate that the failure occurred because the personal email was not configured, and even if the email server was successfully configured, there was no target email address for testing.
    PS: I think this is a bug. The application should remind users that 'your personal email has not been configured yet' instead of causing us trouble. 'Why does it still report an error when I have configured the correct email address?'`

@nano11bravo
Copy link

I have solved my question. If the problem occurs, you can try the following methods to solve it:

  1. Manually configure the email server:
'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',
'mail_smtptimeout' => 30,
'mail_smtpname' => ' [email protected] ',
'mail_smtppassword' => 'supersecretpassword',

Note that it is necessary to add the configuration of 'mail_stmtptimeout'=>30.

  1. At this point, if the newly created email server of NextCloud application still reports an Ajax error, the email transmission will fail. The reason is that the 'admin' account has not been configured with * * personal email * *. I speculate that the failure occurred because the personal email was not configured, and even if the email server was successfully configured, there was no target email address for testing.
    PS: I think this is a bug. The application should remind users that 'your personal email has not been configured yet' instead of causing us trouble. 'Why does it still report an error when I have configured the correct email address?'`

Good to hear.

I tend to agree with you regarding the bug comment.

Maybe some changes to the process of applying smtp configuration and the smtp test feature from the admin panel.

On a freshly created NC setup I replicated this and was forced to manually update the config (even with write permissions).

@FiveTeethless
Copy link

2. At this point, if the newly created email server of NextCloud application still reports an Ajax error, the email transmission will fail. The reason is that the 'admin' account has not been configured with * * personal email * *. I speculate that the failure occurred because the personal email was not configured, and even if the email server was successfully configured, there was no target email address for testing.
   PS: I think this is a bug. The application should remind users that 'your personal email has not been configured yet' instead of causing us trouble. 'Why does it still report an error when I have configured the correct email address?'`

Thank you for this answer.
I was looking everywhere for an issue, but there was simply nothing to find.

After adding an E-Mail address to the profile it just works...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 30-feedback bug feature: emails feature: settings
Projects
None yet
Development

No branches or pull requests

9 participants