Skip to content

[PM-33154] Fix: Handle mail server DNS errors on admin login#7150

Open
boris324 wants to merge 1 commit intobitwarden:mainfrom
boris324:fix/admin-login-mail-dns-error
Open

[PM-33154] Fix: Handle mail server DNS errors on admin login#7150
boris324 wants to merge 1 commit intobitwarden:mainfrom
boris324:fix/admin-login-mail-dns-error

Conversation

@boris324
Copy link

@boris324 boris324 commented Mar 4, 2026

Summary

  • Fixes Unexpected behaviour when mailserver DNS name does not exist #6792
  • When SMTP host DNS is misconfigured, SocketException propagates unhandled from MailKit.Net.Smtp.SmtpClient.ConnectAsync() through LoginController.Index(), resulting in a confusing 404 error page
  • Added try/catch around PasswordlessSignInAsync() to catch the exception, log it, and redirect with a clear error message
  • Added ILogger<LoginController> for proper error logging

Test plan

  • Set globalSettings__mail__smtp__host to non-existent hostname
  • Navigate to /admin/ and enter email address
  • Verify clear error message appears: "There was a problem sending the login email..."
  • Restore valid SMTP host and verify login works normally

When the SMTP host DNS is misconfigured, SocketException propagates
unhandled from MailKit through LoginController.Index(), resulting in
a confusing 404 page. Wrap the passwordless sign-in call in a
try/catch to log the error and display a clear message instead.

Resolves bitwarden#6792
@boris324 boris324 requested a review from a team as a code owner March 4, 2026 21:02
@boris324 boris324 requested a review from rr-bw March 4, 2026 21:02
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@bitwarden-bot
Copy link

Thank you for your contribution! We've added this to our internal tracking system for review.
ID: PM-33154
Link: https://bitwarden.atlassian.net/browse/PM-33154

Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process.

@bitwarden-bot bitwarden-bot changed the title Fix: Handle mail server DNS errors on admin login [PM-33154] Fix: Handle mail server DNS errors on admin login Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected behaviour when mailserver DNS name does not exist

3 participants