[GH-ISSUE #1147] Error "Error sending SMTP test email SmtpError" when setting up SMTP #810

Closed
opened 2026-03-03 02:03:27 +03:00 by kerem · 3 comments
Owner

Originally created by @alexpovel on GitHub (Sep 19, 2020).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/1147

Subject of the issue

As in #537 , I am trying to set up fastmail as the SMTP provider. I've done this successfully many times before, but it is failing here.

In the above issue, the problem was resolved setting SMTP_EXPLICIT_TLS=true. That did not help. The current config shows:

Screenshot_2020-09-19 Bitwarden_rs Admin Panel_Censored

I have tried all combinations possible using the three settings of Port, SSL and Explicit TSL, no dice.

Your environment

  • Bitwarden_rs version: Server: 1.16.3, Web: 2.15.1

Steps to reproduce

Launch using the docker-compose file, where docker-compose config outputs (posting it this way since I also use a .env file among other things, which are likely not relevant here):

networks:
  proxy_default:
    external: true
    name: proxy_default
services:
  app:
    build:
      context: /path/to/bitwarden
    environment:
      ADMIN_TOKEN: secret
      BACKUP_DIR: /mnt/backup/
      DATA_FOLDER: /data
      DOMAIN: https://the.domain.tld
      LETSENCRYPT_HOST: the.domain.tld
      NFS_BACKUP_PATH: secret
      NFS_SHARE_ADDRESS: secret
      SMTP_AUTH_MECHANISM: Plain
      SMTP_EXPLICIT_TLS: "true"
      SMTP_FROM: info@the.domain.tld
      SMTP_FROM_NAME: The Name
      SMTP_HOST: smtp.fastmail.com
      SMTP_PASSWORD: secret
      SMTP_PORT: '465'
      SMTP_SSL: "true"
      SMTP_USERNAME: user@fastmail.com
      VIRTUAL_HOST: the.domain.tld
    networks:
      default: null
      proxy_default: null
    restart: unless-stopped
    volumes:
    - data:/data:rw
    - backup:/mnt/backup:rw
    - /etc/timezone:/etc/timezone:ro
    - /etc/localtime:/etc/localtime:ro
version: '3.8'
volumes:
  backup:
    driver_opts:
      device: :secret: 
      o: addr=secret,nolock,soft,rw
      type: nfs
  data: {}

Dockerfile is:

FROM bitwardenrs/server

RUN apt-get update && apt-get install -y cron rsync

COPY backup/ /backup/

RUN chmod -R 777 /backup/ && crontab /backup/backup.crontab

# This is a manual step that relies on the `/start.sh` script as the entrypoint
# for the parent container. Taken from:
# https://hub.docker.com/r/bitwardenrs/server/dockerfile
# This is required because `cron` won't start on its own after installing.
# See also: https://www.marmanold.com/tech/cron-in-docker-with-debian-slim/
#
# Upon startup/shell login, write environment to file (shell script) to be sourced
# from later on (so cron has environment available).
# See: https://ypereirareis.github.io/blog/2016/02/29/docker-crontab-environment-variables/
CMD service cron start && \
    env | sed 's/^\(.*\)$/export \1/g' > /.env.sh && \
    /start.sh

There is an NFS backup facility and the nginx-proxy stuff that can probably be ignored.

Expected behaviour

Succesfull sending of test email.

Actual behaviour

Sending fails with error message:

Error sending SMTP test email
SmtpError

The below log does not look like it is a Fastmail-specific problem though.

Relevant logs

app_1  | [2020-09-19 15:28:26.342][request][INFO] POST /admin/test/smtp/
app_1  | [2020-09-19 15:28:41.670][error][ERROR] SmtpError.
app_1  | [CAUSE] Io(
app_1  |     Os {
app_1  |         code: 11,
app_1  |         kind: WouldBlock,
app_1  |         message: "Resource temporarily unavailable",
app_1  |     },
app_1  | )
app_1  | [2020-09-19 15:28:41.670][response][INFO] POST /admin/test/smtp (test_smtp) => 400 Bad Request

This is from LOG_LEVEL=info. Setting trace did not seem to output more useful info around that error.

Originally created by @alexpovel on GitHub (Sep 19, 2020). Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/1147 <!-- Please fill out the following template to make solving your problem easier and faster for us. This is only a guideline. If you think that parts are unneccessary for your issue, feel free to remove them. Remember to hide/obfuscate personal and confidential information, such as names, global IP/DNS adresses and especially passwords, if neccessary. --> ### Subject of the issue <!-- Describe your issue here.--> As in #537 , I am trying to set up [fastmail](https://www.fastmail.com/help/technical/servernamesandports.html) as the SMTP provider. I've done this successfully many times before, but it is failing here. In the above issue, the problem was resolved setting `SMTP_EXPLICIT_TLS=true`. That did not help. The current config shows: ![Screenshot_2020-09-19 Bitwarden_rs Admin Panel_Censored](https://user-images.githubusercontent.com/48824213/93668648-0b4b3680-fa8e-11ea-91ad-18a22ebd1132.png) I have tried all combinations possible using the three settings of *Port*, *SSL* and *Explicit TSL*, no dice. ### Your environment <!-- The version number, obtained from the logs or the admin page --> * Bitwarden_rs version: Server: 1.16.3, Web: 2.15.1 <!-- How the server was installed: Docker image / package / built from source --> * Install method: Docker-compose * Reverse proxy and version: https://github.com/nginx-proxy/nginx-proxy ### Steps to reproduce <!-- Tell us how to reproduce this issue. What parameters did you set (differently from the defaults) and how did you start bitwarden_rs? --> Launch using the docker-compose file, where `docker-compose config` outputs (posting it this way since I also use a `.env` file among other things, which are likely not relevant here): ```yaml networks: proxy_default: external: true name: proxy_default services: app: build: context: /path/to/bitwarden environment: ADMIN_TOKEN: secret BACKUP_DIR: /mnt/backup/ DATA_FOLDER: /data DOMAIN: https://the.domain.tld LETSENCRYPT_HOST: the.domain.tld NFS_BACKUP_PATH: secret NFS_SHARE_ADDRESS: secret SMTP_AUTH_MECHANISM: Plain SMTP_EXPLICIT_TLS: "true" SMTP_FROM: info@the.domain.tld SMTP_FROM_NAME: The Name SMTP_HOST: smtp.fastmail.com SMTP_PASSWORD: secret SMTP_PORT: '465' SMTP_SSL: "true" SMTP_USERNAME: user@fastmail.com VIRTUAL_HOST: the.domain.tld networks: default: null proxy_default: null restart: unless-stopped volumes: - data:/data:rw - backup:/mnt/backup:rw - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro version: '3.8' volumes: backup: driver_opts: device: :secret: o: addr=secret,nolock,soft,rw type: nfs data: {} ``` Dockerfile is: ```dockerfile FROM bitwardenrs/server RUN apt-get update && apt-get install -y cron rsync COPY backup/ /backup/ RUN chmod -R 777 /backup/ && crontab /backup/backup.crontab # This is a manual step that relies on the `/start.sh` script as the entrypoint # for the parent container. Taken from: # https://hub.docker.com/r/bitwardenrs/server/dockerfile # This is required because `cron` won't start on its own after installing. # See also: https://www.marmanold.com/tech/cron-in-docker-with-debian-slim/ # # Upon startup/shell login, write environment to file (shell script) to be sourced # from later on (so cron has environment available). # See: https://ypereirareis.github.io/blog/2016/02/29/docker-crontab-environment-variables/ CMD service cron start && \ env | sed 's/^\(.*\)$/export \1/g' > /.env.sh && \ /start.sh ``` There is an NFS backup facility and the `nginx-proxy` stuff that can probably be ignored. ### Expected behaviour <!-- Tell us what should happen --> Succesfull sending of test email. ### Actual behaviour <!-- Tell us what happens instead --> Sending fails with error message: ``` Error sending SMTP test email SmtpError ``` The below log does not look like it is a Fastmail-specific problem though. ### Relevant logs <!-- Share some logfiles, screenshots or output of relevant programs with us. --> ``` app_1 | [2020-09-19 15:28:26.342][request][INFO] POST /admin/test/smtp/ app_1 | [2020-09-19 15:28:41.670][error][ERROR] SmtpError. app_1 | [CAUSE] Io( app_1 | Os { app_1 | code: 11, app_1 | kind: WouldBlock, app_1 | message: "Resource temporarily unavailable", app_1 | }, app_1 | ) app_1 | [2020-09-19 15:28:41.670][response][INFO] POST /admin/test/smtp (test_smtp) => 400 Bad Request ``` This is from `LOG_LEVEL=info`. Setting `trace` did not seem to output more useful info around that error.
kerem closed this issue 2026-03-03 02:03:27 +03:00
Author
Owner

@BlackDex commented on GitHub (Sep 19, 2020):

@alexpovel I think you should put "SMTP_EXPLICIT_TLS" to false here.

<!-- gh-comment-id:695220910 --> @BlackDex commented on GitHub (Sep 19, 2020): @alexpovel I think you should put "SMTP_EXPLICIT_TLS" to false here.
Author
Owner

@BlackDex commented on GitHub (Sep 19, 2020):

Also, if that doesn't work, it looks like the mail server is not reachable from within the container for some reason.

<!-- gh-comment-id:695247318 --> @BlackDex commented on GitHub (Sep 19, 2020): Also, if that doesn't work, it looks like the mail server is not reachable from within the container for some reason.
Author
Owner

@alexpovel commented on GitHub (Sep 19, 2020):

Thank you @BlackDex for those suggestions.

It turns out, restarting via docker-compose allowed it to work, with exactly the settings as shown above in the screenshot.
Pleasant outcome for me, but I recognize the classic "Worked for me after a reboot" might not help any future readers with more serious problems that persist through reboots. I cannot explain what went wrong and was fixed through a reboot.

Considering this fixed, thanks.

<!-- gh-comment-id:695250672 --> @alexpovel commented on GitHub (Sep 19, 2020): Thank you @BlackDex for those suggestions. It turns out, restarting via docker-compose allowed it to work, with exactly the settings as shown above in the screenshot. Pleasant outcome for me, but I recognize the classic "*Worked for me after a reboot*" might not help any future readers with more serious problems that persist through reboots. I cannot explain what went wrong and was fixed through a reboot. Considering this fixed, thanks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vaultwarden#810
No description provided.