Unable to get SMTP function to work

Ok…
What does this tell you??

docker exec vaultwarden nc -vz smtp.office365.com 587

root@vps8773:~# docker exec vaultwarden nc -vz smtp.office365.com 587
OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: “nc”: executable file not found in $PATH: unknown

Of course, the debian image doesn’t have that there by default.
In that case try this:
You need to run this by starting a tty first, so:

docker exec -it vaultwarden bash
timeout 5 bash -c 'cat < /dev/null > /dev/tcp/smtp.office365.com/587'; echo $?

root@vps8773:~# timeout 5 bash -c ‘cat < /dev/null > /dev/tcp/smtp.office365.com/587’; echo $?
124

If I’m correct, you tested that from the host right, not from within the container.
But that also gives the response we didn’t wanted to see.

the 124 response is the timeout being reached, and thus, it wasn’t able to connect to it from the host it self.

What if you try that nc command from the host?

from the docker image i get 124. and the nc command is not found in debian 11

Ok, try the timeout command also on the host then.

timeout 5 bash -c 'cat < /dev/null > /dev/tcp/smtp.office365.com/587'; echo $?

Maybe increase the timeout a bit to 10 or 15.
But if that doesn’t work on the host either then I’m afraid your VPS provider is blocking access to these ports.

Also try the following:

# Port 443 to office365
timeout 5 bash -c 'cat < /dev/null > /dev/tcp/smtp.office365.com/443'; echo $?

# Port 465 to sendgrid
timeout 5 bash -c 'cat < /dev/null > /dev/tcp/smtp.sendgrid.net/465'; echo $?

RIP, 443 on office works 587 not. same goes for sendgrid on the vps and the docker bash

Then I think your VPS Provider is blocking that access.
You might try to check there FAQ’s on this, maybe there is a way to ask if they unblock this somehow for specific hosts maybe?

They probably do this to prevent sending out spam from there network.

Just contacted the vps provider and yes they block the ports. they can enable them, so i will let you know if its fixed

1 Like

My VPS profider did block the ports, they have enabled it now, so everything works. Thank you very much for taking your time to help me figure this out.
With kind regards,
Mathijs

1 Like