/
Pack Hosting Panel

Mailhog

How to use Mailhog through Docker at Hipex?


We often receive questions on how to set up SMTP testing. This can be easily done with Mailhog and Docker. We assume you're familiar with Docker and how to use it. See also our docker documentation.

Service configuration

In the docker service configuration, specify which version of Mailhog use and on which port it has to be available. In this example, Mailhog runs on port 11025 and 18025.

version: "3.2"
services:
     mailhog:
        image: "mailhog/mailhog:latest"
        restart: "always"
        ports:
        - "11025:1025" # smtp server
        - "18025:8025" # web ui

Place this file in a subfolder of your home folder, for example ~/mailhog/docker-compose.yml.

Then start the container with this command:

hipex docker:compose:up --detach

Port bind error

If you get the following error during starting the service: Bind for 0.0.0.0:11025 of 0.0.0.0:18025 failed: port is already allocated. then the chosen port 11025 or 18025 is already in use. In that case, another port has to be chosen.

Use

To use mailhog, we recommend to use a module where this can be set on:

For Magento 1: http://www.aschroder.com/product/smtppro-magento-smtp-email/ For Magento 2: https://github.com/mageplaza/magento-2-smtp

So you can start a ssh tunnel from your local computer:

ssh -L 18025:localhost:18025 <user>@<server> -p 339 -N