SMTP issue: An unhandled server error has occurred on verification email sending

Hello.

I’m using self-hosted Bitwarden with self-hosted Postfix mail server. I’m trying to verify my account with email, but getting this:


At the same time, test of sending message via “mail” command of mailutils package is successful

echo "This is the body of the email" | mail -s "This is the subject line" your_email_address

Can you help me figure it out? Thank you in advance.

main.cf confs:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mail.johnnyluger.tech
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = 211652.fornex.cloud, mail.johnnyluger.tech, 211652.fornex.cloud, localhost.$mydomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

global.override.env:

globalSettings__baseServiceUri__vault=https://bitwarden.johnnyluger.tech
globalSettings__sqlServer__connectionString="Data Source=tcp:mssql,1433;Initial Catalog=vault;Persist Security Info=False;User ID=sa;Password=nMFRBfpwh3N4lXTJmU0SOVWK3YFGQaF7;MultipleActiveResultSets=False;Connect Timeout=30;Encrypt=Tru>globalSettings__identityServer__certificatePassword=lBSspN9U4wA0OJ1TIYVE8FP3htySb4vB
globalSettings__internalIdentityKey=kXe9iedCMMf3xTwcl7KidFYMxrvwvVGZ8ehTExAzEbVIvvBdJKHKfabvxW4xEwps
globalSettings__oidcIdentityClientKey=wTendNLnfLU5WXja3nsuG0m7Na4r2cyMBxrYjvvhJOU0wfffnNU7FmOLKc92mPXX
globalSettings__duo__aKey=Ay7nW3nykXgPN1VWXuc1looVCphWHZkqTRM3xJ2wCo8rZt4bnNjCYaKXzqwGi5oc
globalSettings__installation__id=dd6512ad-e511-41fa-9471-ae6c01619bea
globalSettings__installation__key=LImZQKIUH8ub4qgUvu8T
globalSettings__yubico__clientId=REPLACE
globalSettings__yubico__key=REPLACE
[email protected]r.tech
globalSettings__mail__smtp__host=mail.johnnyluger.tech
globalSettings__mail__smtp__port=25
globalSettings__mail__smtp__ssl=false
globalSettings__mail__smtp__username=
globalSettings__mail__smtp__password=
globalSettings__disableUserRegistration=false
globalSettings__hibpApiKey=REPLACE
adminSettings__admins=

Check your postfix logs. What’s the destination email?

My guess is the email server requires authentication. Easy workaround, put the docker’s range into mynetworks.

Destination email is [email protected]

That’s successful logs from mailutils sending:

Apr  7 12:50:30 211652 postfix/pickup[1352912]: 10CBD800D1: uid=0 from=<[email protected]>
Apr  7 12:50:30 211652 postfix/cleanup[1354616]: 10CBD800D1: message-id=<[email protected]>
Apr  7 12:50:30 211652 postfix/qmgr[1352913]: 10CBD800D1: from=<[email protected]>, size=377, nrcpt=1 (queue active)
Apr  7 12:50:30 211652 postfix/smtp[1354618]: 10CBD800D1: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[74.125.140.26]:25, delay=0.51, delays=0.01/0.01/0.14/0.35, dsn=2.0.0, status=sent (250 2.0.0 OK  1649325030 r12-20020a5d52cc000000b00205932665e7si12419468wrv.772 - gsmtp)
Apr  7 12:50:30 211652 postfix/qmgr[1352913]: 10CBD800D1: removed

And that’s logs of attempts to send message via telnet:

Apr  7 12:51:14 211652 postfix/smtpd[1354915]: connect from 211652.fornex.cloud[31.172.73.45]
Apr  7 12:51:36 211652 postfix/smtpd[1354915]: NOQUEUE: reject: RCPT from 211652.fornex.cloud[31.172.73.45]: 454 4.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=SMTP
Apr  7 12:51:39 211652 postfix/smtpd[1354915]: disconnect from 211652.fornex.cloud[31.172.73.45] mail=1 rcpt=0/1 quit=1 commands=2/3

Try to verify your email again and show the relevant logs from your mailserver.

The logs earlier are not related to Bitwarden.

Apr  7 15:11:49 211652 postfix/smtpd[1443527]: connect from unknown[172.23.0.3]
Apr  7 15:11:49 211652 postfix/smtpd[1443527]: NOQUEUE: reject: RCPT from unknown[172.23.0.3]: 454 4.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<[172.23.0.3]>
Apr  7 15:11:49 211652 postfix/smtpd[1443527]: lost connection after RSET from unknown[172.23.0.3]
Apr  7 15:11:49 211652 postfix/smtpd[1443527]: disconnect from unknown[172.23.0.3] ehlo=1 mail=1 rcpt=0/1 rset=1 commands=3/4

Sorry for the delay.

As you can see, the email is rejected because the email server is not configured to relay your email.

The quickest workaround for this issue is to add 172.16.0.0/16 in mynetworks (Postfix).

It helped, thanks.