Docker Community Forums

Share and learn in the Docker community.

Need help to configure wordpress and smtp mail


(Numericanisons) #1

Hi!

I’m new with docker, docker-compose and wordpress/nginx/smtp… I try to learn how to use them. I also begin with wordpress, nginx, … The last wordpress I use was a package already configured.

My configuration
I have a VPS with ubuntu. Docker and Docker-compose installed.

I use docker-compose with 4 containers (I try this French example) :

  1. Nginx
  2. Mariadb
  3. PHP-FPM with wordpress
  4. Memcached

I can’t send email and despite many research and try, I can’t fix it.

Please correct me if I’m wrong, when I send an email :

  1. Wordpress prepares the email (A/CC/BCC, From, object, content, …)
  2. Wordpress/PHP sends email to Nginx container through SMTP
  3. Nginx send email out of the docker
  4. My VPS send the email

I’m not sure at all…

In this configuration, I’m surpris that there is no mail server. So I try to link another docker : postfix, docker_smtp, enimx, …
I add “WP Mail SMTP” plugin to Wordpress, it seems to use SMTP instead of a common email : no progress.

I’ve installed postfix on my vps, without a container. I can send email by comand line but no way to link it to my wordpress web site.

My questions :

  • Do I need to open some ports to nginx or to wordpress/php?
  • Do I need a container to send email like postfix or PHP/FPM is enough?
  • Is it better to send email through an SMTP service like google or another one?

(Alexandre) #2

You Wordpress/PHP container should be the one sending the email. That is because PHP mail(…) function has no “real” mailing capabilities. All it does is prepare a mail and then hand it over to some binary on the OS to be properly sent.

There’s no port to open and no additional container needed. However, you must remember that Docker image are often based on striped down version of the “full” OS and sometimes you’ll need to configure stuff that may work out of the box if you download the latest Ubuntu, for example.

In your case, the wordpress:fpm image is based on php:5.6-fpm which is based on debian:jessie.

The first thing to understand is whether or not your container has the package and is configured to send email. While searching for that, I found the thread hereunder where people configures their PHP image in order to send email. It would be a good read for you I believe:

HTH,
Alexandre


(Pierre Ozoux) #3

I have a nice fix for you: