Not able to send Verification email from on-premise installation

This is my global.override.env
** Actual info masked by XXXX

[email protected]
globalSettings__mail__smtp__host=127.0.0.1
globalSettings__mail__smtp__port=25
globalSettings__mail__smtp__ssl=false
globalSettings__mail__smtp__username=XXXXX
globalSettings__mail__smtp__password=XXXXXXXXX

I can send emails with ‘mail’ command but bitwarden is not able to send emails(An unhandled server error has occured.)
“telnet 127.0.0.1 25” also works.

XXXX@XXXX:/var/local/BitWarden$ telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
220 postman.XXXX.co.in ESMTP Postfix (Ubuntu)

But bitwarden log says

2022-04-27 18:24:16.156 +00:00 [Error] Connection refused 127.0.0.1:25
System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (111): Connection refused 127.0.0.1:25
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at MailKit.Net.SocketUtils.ConnectAsync(String host, Int32 port, IPEndPoint localEndPoint, Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.SocketUtils.ConnectAsync(String host, Int32 port, IPEndPoint localEndPoint, Int32 timeout, Boolean doAsync, CancellationToken cancellationToken)
at MailKit.MailService.ConnectSocket(String host, Int32 port, Boolean doAsync, CancellationToken cancellationToken)
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 81
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 56
at Bit.Core.Services.UserService.SendEmailVerificationAsync(User user) in /home/runner/work/server/server/src/Core/Services/Implementations/UserService.cs:line 498
at Bit.Api.Controllers.AccountsController.PostVerifyEmail() in /home/runner/work/server/server/src/Api/Controllers/AccountsController.cs:line 181
at lambda_method97(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.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.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2022-04-27 18:29:16.466 +00:00 [Information] Api started.

Inside Bitwarden’s Docker containers, localhost and 127.0.0.1 do not refer to your host system where the mail server is listening.

Depending on your OS, there are several ways to access the host:

1 Like