After setting up the docker containers for WordPress and the NGINX Proxy Manager I still had one open issue: Sending mail was not possible. So I was looking for a solution to set up mail for the WordPress Docker setup.
I had the following options in mind:
- Setting up a separate docker container with an e-mail server. More or less I just needed a so-called Smarthost, that takes sent-out e-mails from any docker container and forwards them to my e-mail provider, Gmail. I struggled to find a proper, small image of a mail server running on an RPi for a long time. Then open the ports of the WordPress containers and send the e-mail from the WordPress containers to the container with the Smarthost Mail server. Nevertheless, you must install any kind of mailer within the container to handle the mail() call coming from WordPress.
- Set up an email server on the host (I used exim4) and let all Docker containers send their e-mails to the host, which will then be forwarded to the real e-mail provider by exim4. Still, you must install any kind of mailer within the container to handle the mail() call coming from WordPress. There were the following sub steps necessary:
- Install and configure exim4
- Setup 2 factor authentication at Google
- Create an App Password for TLS usage
- Make the Let’s encrypt credentials accessible for exim4
- Setup the docker bridge connecting the host
- Setting up a WordPress Plugin, connecting via SMTP to the e-mail provider.
The variants 1 & 2 generated so many problems during the setup, that I finally decided to go with variant #3. This was set up in 30 minutes only!
For this SMTP service, I’m using the plugin WP Mail SMTP.