Docker: Enabling mailing in php:apache (running WordPress)

Starting from

When using the php:apache image from https://hub.docker.com/_/php/ image mail support was not enabled. On my docker host postfix is already enabled and configured to accept and forward mails from my docker containers. So I should be able to send mails.

When I decided to install WordPress by myself, I ended up with this Dockerfile and did config stuff using a volume over /var/www/html:

At the end I realized that mails are not working. Php’s answer when asking for the sendmail_path is this:

And Php mail() result is this:

The manual approach first:

Entering the container:

Then installing sSMTP

and configuring it. Here is my ssmtp.conf

Changing the sendmail_path for Php is easy as there is no php.ini by now:

After restarting the Apache

Php is responding with a valid sendmail_path

Now Php mail() and also WordPress mailing is working fine ;-).

The new Dockerfile:

You need to have the above ssmtp.conf file to build the image.

Markus Neuhold on BehanceMarkus Neuhold on EmailMarkus Neuhold on GithubMarkus Neuhold on Twitter
Markus Neuhold
Markus Neuhold
IBMi (AS400) sysadmin since 1997, linux fanboy and loving open source, docker and all about tech and science.

Published by

Markus Neuhold

IBMi (AS400) sysadmin since 1997, linux fanboy and loving open source, docker and all about tech and science.

Leave a Reply

Your email address will not be published. Required fields are marked *