# Unable to get SMTP function to work

**URL:** <https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882>\
**Category:** Help\
**Created:** [September 17, 2022, 8:22am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882 "2022-09-17T08:22:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 17, 2022, 8:22am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/1 "2022-09-17T08:22:02Z")

</div>

Dear Reader,

I have a problem with the SMTP function in vaultwarden (also with passbolt, tried it if i could get that to work). I have a microsoft exchange account, and I have a SendGrid that I used to get SMTP to work. both of them don’t work. I use the latest variant of Vaultwarden.

SMTP Settings in admin portal:  
Enabled  
Default: true  
Host: [smtp.office365.com](http://smtp.office365.com)  
Secure SMTP: starttls  
Port: 587  
From Address: email address  
From Name: Vaultwarden  
Username: email address  
Password: “the password of the mailaddress”  
SMTP Auth mechanism: “Login”  
SMTP connection timeout: 15  
Server name sent during HELO: -

I have SMTP enabled on the Office account and I have enabled basic authentications. Still nothing.

I get 2 errors:  
[2022-09-17 08:19:25.440][vaultwarden::mail][ERROR] SMTP Connection error: Cannot assign requested address (os error 99)  
[2022-09-17 08:19:25.441][response][INFO] (test\_smtp) POST /admin/test/smtp =\> 400 Bad Request

With kind regards,  
Mathijs

---

<div class="post-metadata">

**Author:** ![BlackDex](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/blackdex/32/8_2.png) [@BlackDex](https://vaultwarden.discourse.group/u/BlackDex)\
**Post date:** [September 17, 2022, 8:52am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/2 "2022-09-17T08:52:45Z")

</div>

Looks like a hostname resolving issues.  
Could you post the `Support String` which you can generate from the diagnostics page?

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 17, 2022, 11:10am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/3 "2022-09-17T11:10:13Z")

</div>

### Your environment (Generated via diagnostics page)

- Vaultwarden version: v1.25.2
- Web-vault version: v2022.6.2
- Running within Docker: true (Base: Debian)
- Environment settings overridden: true
- Uses a reverse proxy: true
- IP Header check: true (X-Real-IP)
- Internet access: true
- Internet access via a proxy: false
- DNS Check: true
- Time Check: true
- Domain Configuration Check: false
- HTTPS Check: true
- Database type: SQLite
- Database version: 3.35.4
- Clients used:
- Reverse proxy and version:
- Other relevant information:

### Config (Generated via diagnostics page)

> **Show Running Config**
>
> **Environment settings which are overridden:** SIGNUPS\_ALLOWED, SIGNUPS\_VERIFY, ADMIN\_TOKEN
> 
> ```json
> {
> "_duo_akey": null,
> "_enable_duo": false,
> "_enable_email_2fa": false,
> "_enable_smtp": true,
> "_enable_yubico": true,
> "_icon_service_csp": "",
> "_icon_service_url": "",
> "_ip_header_enabled": true,
> "admin_ratelimit_max_burst": 3,
> "admin_ratelimit_seconds": 300,
> "admin_token": "***",
> "allowed_iframe_ancestors": "",
> "attachments_folder": "data/attachments",
> "authenticator_disable_time_drift": false,
> "data_folder": "data",
> "database_conn_init": "",
> "database_max_conns": 10,
> "database_timeout": 30,
> "database_url": " ****/**. *******",
> "db_connection_retries": 15,
> "disable_2fa_remember": false,
> "disable_admin_token": false,
> "disable_icon_download": false,
> "domain": " *****://********.**",
> "domain_origin": " *****://********.**",
> "domain_path": "",
> "domain_set": true,
> "duo_host": null,
> "duo_ikey": null,
> "duo_skey": null,
> "email_attempts_limit": 3,
> "email_expiration_time": 600,
> "email_token_size": 6,
> "emergency_access_allowed": true,
> "emergency_notification_reminder_schedule": "0 5 * * * *",
> "emergency_request_timeout_schedule": "0 5 * * * *",
> "enable_db_wal": true,
> "extended_logging": true,
> "helo_name": null,
> "hibp_api_key": null,
> "icon_blacklist_non_global_ips": true,
> "icon_blacklist_regex": null,
> "icon_cache_folder": "data/icon_cache",
> "icon_cache_negttl": 259200,
> "icon_cache_ttl": 2592000,
> "icon_download_timeout": 10,
> "icon_redirect_code": 302,
> "icon_service": "internal",
> "incomplete_2fa_schedule": "30 * * * * *",
> "incomplete_2fa_time_limit": 3,
> "invitation_org_name": "Vaultwarden",
> "invitations_allowed": true,
> "ip_header": "X-Real-IP",
> "job_poll_interval_ms": 30000,
> "log_file": null,
> "log_level": "Info",
> "log_timestamp_format": "%Y-%m-%d %H:%M:%S.%3f",
> "login_ratelimit_max_burst": 10,
> "login_ratelimit_seconds": 60,
> "org_attachment_limit": null,
> "org_creation_users": "",
> "password_hints_allowed": true,
> "password_iterations": 100000,
> "reload_templates": false,
> "require_device_email": false,
> "rsa_key_filename": "data/rsa_key",
> "send_purge_schedule": "0 5 * * * *",
> "sends_allowed": true,
> "sends_folder": "data/sends",
> "show_password_hint": false,
> "signups_allowed": true,
> "signups_domains_whitelist": "",
> "signups_verify": false,
> "signups_verify_resend_limit": 6,
> "signups_verify_resend_time": 3600,
> "smtp_accept_invalid_certs": false,
> "smtp_accept_invalid_hostnames": false,
> "smtp_auth_mechanism": "\"Login\"",
> "smtp_debug": false,
> "smtp_explicit_tls": null,
> "smtp_from": " *****@********.**",
> "smtp_from_name": "relay",
> "smtp_host": " ****.*********.***",
> "smtp_password": "***",
> "smtp_port": 587,
> "smtp_security": "starttls",
> "smtp_ssl": null,
> "smtp_timeout": 15,
> "smtp_username": " *****@********.**",
> "templates_folder": "data/templates",
> "tmp_folder": "data/tmp",
> "trash_auto_delete_days": null,
> "trash_purge_schedule": "0 5 0 * * *",
> "use_syslog": true,
> "user_attachment_limit": null,
> "web_vault_enabled": true,
> "web_vault_folder": "web-vault/",
> "websocket_address": "0.0.0.0",
> "websocket_enabled": false,
> "websocket_port": 3012,
> "yubico_client_id": null,
> "yubico_secret_key": null,
> "yubico_server": null
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![BlackDex](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/blackdex/32/8_2.png) [@BlackDex](https://vaultwarden.discourse.group/u/BlackDex)\
**Post date:** [September 17, 2022, 12:30pm UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/4 "2022-09-17T12:30:21Z")

</div>

Please try to enable debug logging.  
`LOG_LEVEL=debug` (or trace) and `SMTP_DEBUG=true` .

Then try again, and see what the output of the logs tell.

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 17, 2022, 1:57pm UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/5 "2022-09-17T13:57:11Z")

</div>

[2022-09-17 13:55:17.830][request][INFO] GET /alive  
[2022-09-17 13:55:17.831][response][INFO] (alive) GET /alive =\> 200 OK  
[2022-09-17 13:55:47.112][vaultwarden::api::core::two\_factor][DEBUG] Sending notifications for incomplete 2FA logins  
[2022-09-17 13:55:57.215][vaultwarden::mail][DEBUG] SMTP lettre::transport::smtp::Error {  
kind: Connection,  
source: Os {  
code: 99,  
kind: AddrNotAvailable,  
message: “Cannot assign requested address”,  
},  
}  
[2022-09-17 13:55:57.215][vaultwarden::mail][ERROR] SMTP Connection error: Cannot assign requested address (os error 99)  
[2022-09-17 13:55:57.216][response][INFO] (test\_smtp) POST /admin/test/smtp =\> 400 Bad Request  
[2022-09-17 13:56:17.920][request][INFO] GET /alive  
[2022-09-17 13:56:17.920][response][INFO] (alive) GET /alive =\> 200 OK

---

<div class="post-metadata">

**Author:** ![BlackDex](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/blackdex/32/8_2.png) [@BlackDex](https://vaultwarden.discourse.group/u/BlackDex)\
**Post date:** [September 17, 2022, 3:02pm UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/6 "2022-09-17T15:02:42Z")

</div>

Still, it looks like resolving the domain seems to have some issues.  
Could you run the following from the docker host and see if that works?

```bash
docker exec vaultwarden getent hosts smtp.office365.com
# And
docker exec vaultwarden getent ahosts smtp.office365.com

```

Where `vaultwarden` is the name of your container of course.

I just tested sendgrid my self, and it works just fine for me.

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 17, 2022, 5:28pm UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/7 "2022-09-17T17:28:06Z")

</div>

![Screenshot_20220917-192731](https://global.discourse-cdn.com/free1/uploads/vaultwarden/original/1X/3d46c7f330b5593f05228132255df0b8929bbc9b.jpeg)

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 17, 2022, 5:28pm UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/8 "2022-09-17T17:28:47Z")

</div>

I am not allowed to post more links because I am a new user, so I uploaded a screenshot

---

<div class="post-metadata">

**Author:** ![BlackDex](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/blackdex/32/8_2.png) [@BlackDex](https://vaultwarden.discourse.group/u/BlackDex)\
**Post date:** [September 17, 2022, 5:54pm UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/9 "2022-09-17T17:54:07Z")

</div>

Ik could be me, but I’m not seeing any ipv4 addresses. It could be that your docker config is having issues with ipv6 maybe??

I also changed your user level, so links should be possible now.

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 17, 2022, 6:05pm UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/10 "2022-09-17T18:05:29Z")

</div>

version: “2”  
services:  
vaultwarden:  
image: vaultwarden/server:latest  
container\_name: vaultwarden  
volumes:  
- /home/docker/VW:/data/  
ports:  
-8080:80  
networks:  
ngx:  
ipv4\_address: 172.19.0.3  
restart: unless-stopped  
environment:  
- LOG\_LEVEL=debug  
- SMTP\_DEBUG=true  
- SIGNUPS\_ALLOWED=true  
- USE\_SYSLOG=true  
- SIGNUPS\_VERIFY=false  
- EXTENDED\_LOGGING=true  
- ADMIN\_TOKEN=password  
networks:  
ngx:  
external: true

This is my docker-compose.yml

---

<div class="post-metadata">

**Author:** ![BlackDex](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/blackdex/32/8_2.png) [@BlackDex](https://vaultwarden.discourse.group/u/BlackDex)\
**Post date:** [September 17, 2022, 9:46pm UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/11 "2022-09-17T21:46:36Z")

</div>

Hmm, i think it had something to do with ipv6. Like, it tries to use ipv6, but it can’t connect to it and causes this failure.

Maybe try to add the following to the compose file.

```nohighlight
    sysctls:
      - "net.ipv6.conf.all.disable_ipv6=1"

```

That should disable all ipv6 within the container, maybe that will help.

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 18, 2022, 6:51am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/12 "2022-09-18T06:51:54Z")

</div>

[2022-09-18 06:49:08.263][vaultwarden::mail][ERROR] SMTP Connection error: Cannot assign requested address (os error 99)  
[2022-09-18 06:49:08.264][response][INFO] (test\_smtp) POST /admin/test/smtp =\> 400 Bad Request  
[2022-09-18 06:49:08.264][\_][WARN] Remote left: client disconnect before response started.  
[2022-09-18 06:49:54.536][vaultwarden::api::core::two\_factor][DEBUG] Sending notifications for incomplete 2FA logins  
[2022-09-18 06:49:54.751][request][INFO] GET /alive  
[2022-09-18 06:49:54.752][response][INFO] (alive) GET /alive =\> 200 OK  
[2022-09-18 06:50:07.835][vaultwarden::mail][DEBUG] SMTP lettre::transport::smtp::Error {  
kind: Connection,  
source: Os {  
code: 99,  
kind: AddrNotAvailable,  
message: “Cannot assign requested address”,  
},  
}  
[2022-09-18 06:50:07.835][vaultwarden::mail][ERROR] SMTP Connection error: Cannot assign requested address (os error 99)  
[2022-09-18 06:50:07.836][response][INFO] (test\_smtp) POST /admin/test/smtp =\> 400 Bad Request  
Again… Same error

---

<div class="post-metadata">

**Author:** ![BlackDex](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/blackdex/32/8_2.png) [@BlackDex](https://vaultwarden.discourse.group/u/BlackDex)\
**Post date:** [September 18, 2022, 7:33am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/13 "2022-09-18T07:33:26Z")

</div>

Very strange. Still looks like it can’t resolve or either connect to the ip for some reason.

Could you set the logging to trace and see if that provides some more info.

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 18, 2022, 8:11am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/14 "2022-09-18T08:11:06Z")

</div>

[2022-09-18 08:09:22.249][vaultwarden::mail][DEBUG] SMTP lettre::transport::smtp::Error {  
kind: Connection,  
source: Os {  
code: 99,  
kind: AddrNotAvailable,  
message: “Cannot assign requested address”,  
},  
}  
[2022-09-18 08:09:22.249][vaultwarden::mail][ERROR] SMTP Connection error: Cannot assign requested address (os error 99)  
[2022-09-18 08:09:22.250][response][INFO] (test\_smtp) POST /admin/test/smtp =\> 400 Bad Request  
[2022-09-18 08:09:22.250][tracing::span][TRACE] encode\_headers;  
[2022-09-18 08:09:22.250][tracing::span::active][TRACE] → encode\_headers;  
[2022-09-18 08:09:22.250][tracing::span::active][TRACE] ← encode\_headers;  
[2022-09-18 08:09:22.250][tracing::span][TRACE] – encode\_headers;  
[2022-09-18 08:09:22.250][mio::poll][TRACE] deregistering event source from poller

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 18, 2022, 8:25am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/15 "2022-09-18T08:25:13Z")

</div>

Do I need to put “” or around the smtp address or is it just plain text?

---

<div class="post-metadata">

**Author:** ![BlackDex](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/blackdex/32/8_2.png) [@BlackDex](https://vaultwarden.discourse.group/u/BlackDex)\
**Post date:** [September 18, 2022, 9:29am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/16 "2022-09-18T09:29:35Z")

</div>

Just plain/text is more then enough, no quotes needed.  
Same goes for all others btw, unless there are some special characters in there or spaces, which for domains and email addresses isn’t the case.

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 18, 2022, 9:31am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/17 "2022-09-18T09:31:17Z")

</div>

And for the authentication?

---

<div class="post-metadata">

**Author:** ![BlackDex](https://yyz2.discourse-cdn.com/free1/user_avatar/vaultwarden.discourse.group/blackdex/32/8_2.png) [@BlackDex](https://vaultwarden.discourse.group/u/BlackDex)\
**Post date:** [September 18, 2022, 9:52am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/18 "2022-09-18T09:52:53Z")

</div>

Of you refer to `smtp_auth_mechanism`, that can be without quotes too, but that shouldn’t matter that much.

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 18, 2022, 10:08am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/19 "2022-09-18T10:08:31Z")

</div>

hmm. Should we try a different smtp service provider? maybe we get more info than that of office365.

---

<div class="post-metadata">

**Author:** ![matties02](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@matties02](https://vaultwarden.discourse.group/u/matties02)\
**Post date:** [September 18, 2022, 10:15am UTC](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882/20 "2022-09-18T10:15:13Z")

</div>

with the smtp settings for sendgrid i get this:  
[2022-09-18 10:11:42.616][request][INFO] GET /alive  
[2022-09-18 10:11:42.616][response][INFO] (alive) GET /alive =\> 200 OK  
[2022-09-18 10:12:03.178][vaultwarden::mail][DEBUG] SMTP timeout error: lettre::transport::smtp::Error {  
kind: Connection,  
source: Custom {  
kind: TimedOut,  
error: “connection timed out”,  
},  
}  
[2022-09-18 10:12:03.179][vaultwarden::mail][ERROR] SMTP timeout error: Connection error: connection timed out  
[2022-09-18 10:12:03.180][response][INFO] (test\_smtp) POST /admin/test/smtp =\> 400 Bad Request

Enabled: true  
Host: [smtp.sendgrid.net](http://smtp.sendgrid.net)  
Secure SMTP: starttls  
Port: 587  
From Address: [relay@domain.com](mailto:relay@domain.com)  
From Name: relay  
Username: apikey  
Password: “the api key”  
SMTP Auth mechanism: “Login”  
SMTP connection timeout: 15

[Next page](https://vaultwarden.discourse.group/t/unable-to-get-smtp-function-to-work/1882.md?page=2)
