[GH-ISSUE #6360] [Bug]: Enable smtp, but still prompt smtpHostNotConfiguring after filling in the host #4317

Closed
opened 2026-10-31 20:38:46 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @qjds on GitHub (Aug 29, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6360

Describe the bug

After correctly filling in the smtp host, whether clicking the send test email or save button, it will prompt smtpHostNotConfiguring, and whether filling in all or only the smtp host is the same

How to reproduce the problem

After correctly filling in the smtp host, click the save or send test email button

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.7.0

Xray-core version

26.7.28

How did you install 3x-ui?

install.sh script

Operating system

ubuntu 26.04

Which parts of the panel are affected?

Backend (API endpoints, login, settings)

Browser (only if it is a UI bug)

edge 151.0.4129.107

Is the panel behind a reverse proxy or CDN?

Yes — Cloudflare (proxied DNS)

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @qjds on GitHub (Aug 29, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6360 ### Describe the bug After correctly filling in the smtp host, whether clicking the send test email or save button, it will prompt smtpHostNotConfiguring, and whether filling in all or only the smtp host is the same ### How to reproduce the problem After correctly filling in the smtp host, click the save or send test email button ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.7.0 ### Xray-core version 26.7.28 ### How did you install 3x-ui? install.sh script ### Operating system ubuntu 26.04 ### Which parts of the panel are affected? Backend (API endpoints, login, settings) ### Browser (only if it is a UI bug) edge 151.0.4129.107 ### Is the panel behind a reverse proxy or CDN? Yes — Cloudflare (proxied DNS) ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:38:46 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@NgaiYeanCoi commented on GitHub (Aug 29, 2026):

Image Did you save the SMTP settings? After saving them, did you restart the panel before clicking “Send Test Email”?
<!-- gh-comment-id:5461269998 --> @NgaiYeanCoi commented on GitHub (Aug 29, 2026): <img width="1365" height="871" alt="Image" src="https://github.com/user-attachments/assets/6897abce-885d-414d-9da6-47e050469d03" /> Did you save the SMTP settings? After saving them, did you restart the panel before clicking “Send Test Email”?
Author
Owner

@github-actions[bot] commented on GitHub (Aug 29, 2026):

Short answer: "Send test email" tests the saved SMTP settings, not what is currently typed in the form. Typing the host into the field changes only the browser-side draft — the test request carries no body, so the backend still reads the empty smtpHost row from the settings table and returns smtpHostNotConfigured. Click Save (the button in the header card at the top of Panel → Settings, it is enabled only while there are unsaved changes), then click Send test email.

The request sends nothing:

// frontend/src/pages/settings/EmailTab.tsx:41
const res = (await HttpUtil.post('/panel/api/setting/testSmtp')) as SmtpTestResult;

and the handler reads the persisted value:

// internal/web/service/email/email.go:110-113
host, err := s.settingService.GetSmtpHost()
if err != nil || host == "" {
    return SMTPTestResult{false, "connect", "smtpHostNotConfigured"}
}

GetSmtpHost() is a plain DB read (internal/web/service/setting.go:1099-1101 → getString("smtpHost") → internal/web/service/setting.go:346-358), with no cache in between. The Telegram test button (/panel/api/setting/testTgBot) works the same way.

On the Save button showing the same message: it cannot. /panel/api/setting/update has exactly one response string, pages.settings.toasts.modifySettings (internal/web/controller/setting.go:174); the text smtpHostNotConfigured exists in only one place in the whole backend, the line quoted above. What you are most likely seeing is the previous test's alert still on screen — testResult is cleared only when a new test starts (EmailTab.tsx:39) or when you close the alert yourself (EmailTab.tsx:207), so it survives a save.

If it still fails after a successful save, please add:

  1. The exact text of the toast that appears at the top of the page right after you click Save (copy it as text, not a screenshot — I cannot read images).
  2. Whether the SMTP Host field still shows your value after a hard reload (Ctrl-F5) of Panel → Settings → Email. If it comes back blank, the save is failing and that is the real bug.
  3. The panel log lines around the test — x-ui log, look for SMTP test: starting... and SMTP test failed at ... (internal/web/controller/setting.go:296-299). The "Relevant logs" section of your report was empty.

Also note the test needs more than the host: with SMTP From/SMTP Username both empty you will get smtpFromNotConfigured, and with SMTP To empty, smtpNoRecipients (internal/web/service/email/email.go:129-137).


Verdict: Not a bug (user configuration)
Severity: N/A for the reported symptom (two unrelated defects found in the same code path are noted below, both Low)
Confidence: High on the mechanism; Medium that it fully explains this report, because I cannot verify the reporter's save succeeded
Root cause: No defect in the reported path. EmailTab.handleTestSmtp (frontend/src/pages/settings/EmailTab.tsx:37-51) POSTs /panel/api/setting/testSmtp with no body, and EmailService.TestConnection (internal/web/service/email/email.go:110-113) reads smtpHost from the settings table, so unsaved form edits are invisible to it. Triggering condition: pressing the test button before pressing Save.
Already fixed: Not applicable — behaviour is unchanged on the default branch (f727d04f, v3.7.0)
Duplicate of: None
Evidence:

  • frontend/src/pages/settings/EmailTab.tsx:41 — const res = (await HttpUtil.post('/panel/api/setting/testSmtp')) as SmtpTestResult; (no payload)
  • internal/web/controller/setting.go:297 — result := emailService.TestConnection() (no form binding in testSmtp, lines 291-313)
  • internal/web/service/email/email.go:112 — return SMTPTestResult{false, "connect", "smtpHostNotConfigured"}
  • internal/web/service/setting.go:346-358 — getString hits GORM directly; no settings cache to go stale
  • internal/web/service/setting.go:1199-1247 — UpdateAllSetting writes every entity.AllSetting field by its json tag, including smtpHost (internal/web/entity/entity.go:53); CheckValid (internal/web/entity/entity.go:194-298) validates SmtpFrom only, never SmtpHost
  • internal/web/controller/setting.go:174 — the save endpoint's only message key is pages.settings.toasts.modifySettings
  • internal/web/service/email/email_test.go:183-206 (TestConnectionReportsMissingFrom) pins that TestConnection reads settings from the DB
    Not determined: Whether the reporter's save actually persisted. Item 2 above (does the host survive a hard reload) settles it in one check.

Also found while investigating — two separate defects, present since eec030f8 (v3.4.0), still on the default branch

Not the cause of this report, but they hit the same button as soon as the host is configured and the connection then fails:

  1. Double i18n prefix. classifySMTPError returns keys that already carry the prefix — internal/web/service/email/email.go:331 return "pages.settings.smtpErrorAuth" — while the frontend prefixes again: internal/web/service/email/email.go results are rendered as t('pages.settings.' + testResult.msg) (frontend/src/pages/settings/EmailTab.tsx:202). The lookup becomes pages.settings.pages.settings.smtpErrorAuth, which does not exist, and frontend/src/i18n/react.ts:27-33 sets no parseMissingKeyHandler, so the alert shows the raw key instead of "Authentication failed — check username and password". The four bare returns in TestConnection (smtpHostNotConfigured, smtpFromNotConfigured, smtpNoRecipients, smtpTestSuccess) are unprefixed, so those resolve correctly — the two conventions disagree inside one function.

  2. smtpErrorUnknown can never resolve. internal/web/service/email/email.go:345 returns fmt.Sprintf("pages.settings.smtpErrorUnknown: %s", msg) — a key with the raw error concatenated onto it. Separately, its English value "smtpErrorUnknown": "SMTP error: {{ .Error }}" (internal/web/translation/en-US.json:1514) uses Go template syntax, while i18next here is initialised with interpolation: { escapeValue: false, prefix: '{', suffix: '}' } (frontend/src/i18n/react.ts:31), so the placeholder would not be filled even if the key were reachable.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5461272350 --> @github-actions[bot] commented on GitHub (Aug 29, 2026): **Short answer: "Send test email" tests the *saved* SMTP settings, not what is currently typed in the form.** Typing the host into the field changes only the browser-side draft — the test request carries no body, so the backend still reads the empty `smtpHost` row from the settings table and returns `smtpHostNotConfigured`. Click **Save** (the button in the header card at the top of Panel → Settings, it is enabled only while there are unsaved changes), *then* click **Send test email**. The request sends nothing: ```ts // frontend/src/pages/settings/EmailTab.tsx:41 const res = (await HttpUtil.post('/panel/api/setting/testSmtp')) as SmtpTestResult; ``` and the handler reads the persisted value: ```go // internal/web/service/email/email.go:110-113 host, err := s.settingService.GetSmtpHost() if err != nil || host == "" { return SMTPTestResult{false, "connect", "smtpHostNotConfigured"} } ``` `GetSmtpHost()` is a plain DB read (`internal/web/service/setting.go:1099-1101` → `getString("smtpHost")` → `internal/web/service/setting.go:346-358`), with no cache in between. The Telegram test button (`/panel/api/setting/testTgBot`) works the same way. **On the Save button showing the same message:** it cannot. `/panel/api/setting/update` has exactly one response string, `pages.settings.toasts.modifySettings` (`internal/web/controller/setting.go:174`); the text `smtpHostNotConfigured` exists in only one place in the whole backend, the line quoted above. What you are most likely seeing is the *previous* test's alert still on screen — `testResult` is cleared only when a new test starts (`EmailTab.tsx:39`) or when you close the alert yourself (`EmailTab.tsx:207`), so it survives a save. If it still fails **after** a successful save, please add: 1. The exact text of the toast that appears at the top of the page right after you click **Save** (copy it as text, not a screenshot — I cannot read images). 2. Whether the **SMTP Host** field still shows your value after a hard reload (Ctrl-F5) of Panel → Settings → Email. If it comes back blank, the save is failing and that is the real bug. 3. The panel log lines around the test — `x-ui log`, look for `SMTP test: starting...` and `SMTP test failed at ...` (`internal/web/controller/setting.go:296-299`). The "Relevant logs" section of your report was empty. Also note the test needs more than the host: with `SMTP From`/`SMTP Username` both empty you will get `smtpFromNotConfigured`, and with `SMTP To` empty, `smtpNoRecipients` (`internal/web/service/email/email.go:129-137`). --- Verdict: Not a bug (user configuration) Severity: N/A for the reported symptom (two unrelated defects found in the same code path are noted below, both Low) Confidence: High on the mechanism; Medium that it fully explains this report, because I cannot verify the reporter's save succeeded Root cause: No defect in the reported path. `EmailTab.handleTestSmtp` (`frontend/src/pages/settings/EmailTab.tsx:37-51`) POSTs `/panel/api/setting/testSmtp` with no body, and `EmailService.TestConnection` (`internal/web/service/email/email.go:110-113`) reads `smtpHost` from the settings table, so unsaved form edits are invisible to it. Triggering condition: pressing the test button before pressing Save. Already fixed: Not applicable — behaviour is unchanged on the default branch (f727d04f, v3.7.0) Duplicate of: None Evidence: - `frontend/src/pages/settings/EmailTab.tsx:41` — `const res = (await HttpUtil.post('/panel/api/setting/testSmtp')) as SmtpTestResult;` (no payload) - `internal/web/controller/setting.go:297` — `result := emailService.TestConnection()` (no form binding in `testSmtp`, lines 291-313) - `internal/web/service/email/email.go:112` — `return SMTPTestResult{false, "connect", "smtpHostNotConfigured"}` - `internal/web/service/setting.go:346-358` — `getString` hits GORM directly; no settings cache to go stale - `internal/web/service/setting.go:1199-1247` — `UpdateAllSetting` writes every `entity.AllSetting` field by its `json` tag, including `smtpHost` (`internal/web/entity/entity.go:53`); `CheckValid` (`internal/web/entity/entity.go:194-298`) validates `SmtpFrom` only, never `SmtpHost` - `internal/web/controller/setting.go:174` — the save endpoint's only message key is `pages.settings.toasts.modifySettings` - `internal/web/service/email/email_test.go:183-206` (`TestConnectionReportsMissingFrom`) pins that `TestConnection` reads settings from the DB Not determined: Whether the reporter's save actually persisted. Item 2 above (does the host survive a hard reload) settles it in one check. ### Also found while investigating — two separate defects, present since eec030f8 (v3.4.0), still on the default branch Not the cause of this report, but they hit the same button as soon as the host *is* configured and the connection then fails: 1. **Double i18n prefix.** `classifySMTPError` returns keys that already carry the prefix — `internal/web/service/email/email.go:331` `return "pages.settings.smtpErrorAuth"` — while the frontend prefixes again: `internal/web/service/email/email.go` results are rendered as `t('pages.settings.' + testResult.msg)` (`frontend/src/pages/settings/EmailTab.tsx:202`). The lookup becomes `pages.settings.pages.settings.smtpErrorAuth`, which does not exist, and `frontend/src/i18n/react.ts:27-33` sets no `parseMissingKeyHandler`, so the alert shows the raw key instead of "Authentication failed — check username and password". The four bare returns in `TestConnection` (`smtpHostNotConfigured`, `smtpFromNotConfigured`, `smtpNoRecipients`, `smtpTestSuccess`) are unprefixed, so those resolve correctly — the two conventions disagree inside one function. 2. **`smtpErrorUnknown` can never resolve.** `internal/web/service/email/email.go:345` returns `fmt.Sprintf("pages.settings.smtpErrorUnknown: %s", msg)` — a key with the raw error concatenated onto it. Separately, its English value `"smtpErrorUnknown": "SMTP error: {{ .Error }}"` (`internal/web/translation/en-US.json:1514`) uses Go template syntax, while i18next here is initialised with `interpolation: { escapeValue: false, prefix: '{', suffix: '}' }` (`frontend/src/i18n/react.ts:31`), so the placeholder would not be filled even if the key were reachable. *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@qjds commented on GitHub (Aug 29, 2026):

Clicking the save button will still result in the error session MaxAge: Invalid input

Image
<!-- gh-comment-id:5461289222 --> @qjds commented on GitHub (Aug 29, 2026): Clicking the save button will still result in the error session MaxAge: Invalid input <img width="2297" height="906" alt="Image" src="https://github.com/user-attachments/assets/179fb44b-072f-4941-a22d-b47ddd362db9" />
Author
Owner

@NgaiYeanCoi commented on GitHub (Aug 29, 2026):

Because the entire settings form fails validation, smtpHost is never persisted, so “Send Test Email” reports that the SMTP host is not configured.

Please open General Settings, set “Session Duration” to a valid integer between 60 and 525600 minutes (the default is 360), save the settings again, and then retry the SMTP test.

Image

This appears to be related to #4681 rather than an SMTP-specific issue.

<!-- gh-comment-id:5461306944 --> @NgaiYeanCoi commented on GitHub (Aug 29, 2026): Because the entire settings form fails validation, `smtpHost` is never persisted, so “Send Test Email” reports that the SMTP host is not configured. Please open General Settings, set “Session Duration” to a valid integer between 60 and 525600 minutes (the default is 360), save the settings again, and then retry the SMTP test. <img width="1206" height="811" alt="Image" src="https://github.com/user-attachments/assets/af7b5c34-b411-4517-99b6-63f3d55869a7" /> This appears to be related to #4681 rather than an SMTP-specific issue.
Author
Owner

@qjds commented on GitHub (Aug 29, 2026):

Yes, this solves the problem. I don't know why the value here is 0. Maybe I have set it before, but shouldn't 0 be non expired

<!-- gh-comment-id:5461333494 --> @qjds commented on GitHub (Aug 29, 2026): Yes, this solves the problem. I don't know why the value here is 0. Maybe I have set it before, but shouldn't 0 be non expired
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4317
No description provided.