Timeout While Sending Verification Email

Dashboard works fine otherwise, it’s just the confirmation and admin emails I can’t receive. I’m using gmail for smtp. My settings:

globalSettings__mail__replyToEmail=<myemail>@gmail.com
globalSettings__mail__smtp__host=smtp.gmail.com
globalSettings__mail__smtp__port=465
globalSettings__mail__smtp__ssl=true
globalSettings__mail__smtp__username=<myemail>@gmail.com
globalSettings__mail__smtp__password=<gmail app password>
globalSettings__mail__smtp__useDefaultCredentials=false

I’ve no idea what the useDefaultCredentials setting does, can’t find any docs on it, it’s not there originally but I’ve seen it in several adjacent issues so I thought I’d try it. Between every change that I make I do

bitwarden.sh rebuild
bitwarden.sh update

Error from docker logs bitwarden-api

Summary
fail: Bit.Api.Utilities.ExceptionHandlerFilterAttribute[0]
      => SpanId:xxxx, TraceId:xxxx, ParentId:xxxx => ConnectionId:xxxx => RequestPath:/accounts/verify-email RequestId:xxxx:xxxx => Bit.Api.Controllers.AccountsController.PostVerifyEmail (Api)
      An error occurred while attempting to establish an SSL or TLS connection.
      
      This usually means that the SSL certificate presented by the server is not trusted by the system for one or more of
      the following reasons:
      
      1. The server is using a self-signed certificate which cannot be verified.
      2. The local system is missing a Root or Intermediate certificate needed to verify the server's certificate.
      3. A Certificate Authority CRL server for one or more of the certificates in the chain is temporarily unavailable.
      4. The certificate presented by the server is expired or invalid.
      5. The set of SSL/TLS protocols supported by the client and server do not match.
      6. You are trying to connect to a port which does not support SSL/TLS.
      
      See https://github.com/jstedfast/MailKit/blob/master/FAQ.md#SslHandshakeException for possible solutions.
      
      MailKit.Security.SslHandshakeException: An error occurred while attempting to establish an SSL or TLS connection.
      
      This usually means that the SSL certificate presented by the server is not trusted by the system for one or more of
      the following reasons:
      
      1. The server is using a self-signed certificate which cannot be verified.
      2. The local system is missing a Root or Intermediate certificate needed to verify the server's certificate.
      3. A Certificate Authority CRL server for one or more of the certificates in the chain is temporarily unavailable.
      4. The certificate presented by the server is expired or invalid.
      5. The set of SSL/TLS protocols supported by the client and server do not match.
      6. You are trying to connect to a port which does not support SSL/TLS.
      
      See https://github.com/jstedfast/MailKit/blob/master/FAQ.md#SslHandshakeException for possible solutions.
      
       ---> System.TimeoutException: Operation timed out after 120000 milliseconds
       ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
         at MailKit.Net.NetworkStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
         at MailKit.Net.NetworkStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
         at System.Net.Security.SslStream.<FillHandshakeBufferAsync>g__InternalFillHandshakeBufferAsync|189_0[TIOAdapter](TIOAdapter adap, ValueTask`1 task, Int32 minSize)
         at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter)
         at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
         at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, Boolean doAsync, CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
         at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, Boolean doAsync, CancellationToken cancellationToken)
         at Bit.Core.Services.MailKitSmtpMailDeliveryService.SendEmailAsync(MailMessage message) in /home/runner/work/server/server/src/Core/Services/Implementations/MailKitSmtpMailDeliveryService.cs:line 86
         at Bit.Core.Services.HandlebarsMailService.SendVerifyEmailEmailAsync(String email, Guid userId, String token) in /home/runner/work/server/server/src/Core/Services/Implementations/HandlebarsMailService.cs:line 53
         at Bit.Core.Services.UserService.SendEmailVerificationAsync(User user) in /home/runner/work/server/server/src/Core/Services/Implementations/UserService.cs:line 513
         at Bit.Api.Controllers.AccountsController.PostVerifyEmail() in /home/runner/work/server/server/src/Api/Controllers/AccountsController.cs:line 194
         at lambda_method54(Closure , Object )
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

Issue is similar to this post, there’s a 504 returned somewhere along the way. I opened the dev log, so I have the actual text of the red error message from the other post, though theirs seems to be related to nginx, mine is something from cloudflare:

Summary

(I tried to post the raw HTML but I think I was being blocked, so here’s the resulting text.)

Gateway time-out Error code 504
Visit cloudflare.com for more information.
2023-12-03 03:04:27 UTC
You
Browser
Working
Vancouver
Cloudflare
Working
[my domain]
Host
Error
What happened?

The web server reported a gateway time-out error.
What can I do?

Please try again in a few minutes.

Cloudflare Ray ID: xxxxxxxxx • Your IP:
xxxxxxx • Performance & security by Cloudflare

Hi @braaedy, welcome to Community! :wave:

We have seen issues with Google disabling app passwords, and recommend using a different SMTP provider. This error is related to the TLS certificate on your configured mail server and there may be something with TLS interception preventing the connection from working.

I hope those tips help, but if you need more assistance, please feel free to reach out to our Support Team!