Testing PHPMailer and SMTP to send emails


I have a webapp that uses PHPMailer and its SMTP method to send out emails; in other words, it doesn’t use the mail() command in PHP, but opens a connection to the SMTP port of the given mail server.

How can I test this app using devilbox? Does the default Postfix installation allow SMTP connections? Or do I have to install Mailhog?

Responding to my own question: I had to install Mailhog. But first, I had to correct a minor issue in Mailhog’s example docker-compose.yml (I’ll open a Github issue about it later), and then I had to take note of Mailhog’s container’s IP address, and use it for the SMTP server in my code. (By default its

Once I did both things, it worked beautifully.

Does the thing what you did relate to this part of the documentation ?


I’m asking, because if it does, then you could extend the documentation with what you did.

I was going to, but… well, it’s very odd. Mailhog’s example docker-compose.yml says the following in the “ports” section:


But when I tried to start it up, Docker just gave me error messages about that parameter being wrong. In the end, the only way I found to make it work was to edit it to this:


So yesterday, before opening the Github issue, I tried to confirm this bug. I stopped my containers, put the original Mailhog’s docker-compose.override.yml (the one with the first line above) and then did “docker-compose up -d” again… and it worked.

So now I don’t know if the example file is wrong or there’s something else going on. I’m by no means a Docker expert, and I don’t know which is the right syntax, so in the end I didn’t open the GitHub issue, since I don’t even know whether it’s a bug or not.

We could wait until @cytopia comes back and discuss this issue further.