First login of a new device takes very long - Email misconfiguration?

Hi there,

i have currently an issue with new devices logging into Vaultwarden, no matter if Desktop, iOS, Browser Extension or Web UI itself. It takes very long for the login form accepting the login.
I have a strong suspicion that this has something to do with the server trying to send out a notification mail about that. This is what’s mentioned in the log:

[2024-06-27 10:01:02.158][request][INFO] PUT /api/devices/identifier/9eb0409d-73c2-43c5-b05f-b7f07f6ace6b/token
[2024-06-27 10:01:02.528][response][INFO] (put_device_token) PUT /api/devices/identifier/<uuid>/token => 200 OK
[2024-06-27 10:01:04.358][request][INFO] GET /icons/www.idrive.com/icon.png
[2024-06-27 10:01:04.417][response][INFO] (icon_internal) GET /icons/<domain>/icon.png => 200 OK
[2024-06-27 10:01:04.459][request][INFO] GET /icons/www.idrive.com/icon.png
[2024-06-27 10:01:04.460][response][INFO] (icon_internal) GET /icons/<domain>/icon.png => 200 OK
[2024-06-27 10:02:44.806][request][INFO] GET /api/devices/knowndevice
[2024-06-27 10:02:44.808][response][INFO] (get_known_device) GET /api/devices/knowndevice => 200 OK
[2024-06-27 10:02:51.122][request][INFO] GET /api/devices/knowndevice
[2024-06-27 10:02:51.123][response][INFO] (get_known_device) GET /api/devices/knowndevice => 200 OK
[2024-06-27 10:02:57.494][request][INFO] POST /identity/accounts/prelogin
[2024-06-27 10:02:57.495][response][INFO] (prelogin) POST /identity/accounts/prelogin => 200 OK
[2024-06-27 10:02:57.588][request][INFO] POST /identity/connect/token
[2024-06-27 10:07:57.977][vaultwarden::mail][ERROR] SMTP error: response error: incomplete response
[2024-06-27 10:07:57.980][vaultwarden::api::identity][ERROR] Error sending new device email: SMTP error: response error: incomplete response
[2024-06-27 10:07:57.982][vaultwarden::api::identity][INFO] User xxxxxxxxx logged in successfully. IP: xxxxxxxx
[2024-06-27 10:07:57.983][response][INFO] (login) POST /identity/connect/token => 200 OK
[2024-06-27 10:08:17.823][request][INFO] GET /notifications/hub

As you see, the SMTP process returns after 5 minutes, and only when it returns, the login process proceeds and ultimately is successful. Is that correct that the SMTP subprocess causes the login to hang until it returns?

Also, regarding this SMTP issue: I have set the environment variables of the docker deployment to the right values which my email provider has documented. I am still unsure why i get the incomplete response log message. I have also set SMTP_DEBUG to true to get any more information, but apparently with this flag, this is everything what the logs tell me. For reference, these are the settings:

      SMTP_HOST: "smtp.mailbox.org"
      SMTP_FROM: "vaultwarden-noreply@mydomain.tld"
      SMTP_PORT: "465"
      SMTP_USERNAME: "myusername@mailbox.org"
      SMTP_PASSWORD: "topsecret"
      SMTP_SECURITY: "starttls"
      SMTP_DEBUG: "true"

Has anyone an idea what could cause the incomplete response? Are there any other debug flags i can set to maximum verbosity? I’d like to resolve this problem, since it is quite annoying.

I doubt that the SMTP_DEBUG setting is active, it doesn’t show any debug log at all.
Be sure to re-create the container, restarting will not help.

Also, during startup it would show you a warning that SMTP_DEBUG is enabled!

Via the /admin interface you can test the SMTP by sending a mail there, which should help in troubleshooting your issues.

I got the warning, that’s why i find it so funny.
However, in the meantime i stumbled about the different SMTP TLS settings and changed starttls to force_tls, since apparently for starttls you have to use port 587 at my mail provider. I think i have figured it out.