Unable to get SMTP function to work

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?

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.