How to send email from WordPress (contact forms) in Docker container?

Solution:

You can install ssmtp, as in : https://github.com/xgodon/RIG/blob/master/dockerized-apps/wordpress/Dockerfile

you just need a ssmtp.conf file like

mailhub=smtp.gmail.com:587
AuthUser=xxx@mail.com
AuthPass=
UseSTARTTLS=YES
# Allow the "From" email header.
FromLineOverride=YES

there is a delay (beacause no qualified host name) in the sending but here is the solution : https://www.digitalocean.com/community/questions/sendmail-is-slow-to-send-mail

i’ll update the Dockerfile soon.