Enable and configure MailHog¶
This section will guide you through getting MailHog integrated into the Devilbox.
Table of Contents
The Devilbox ships various example configurations to overwrite the default stack. Those files are
compose/ in the Devilbox git directory.
docker-compose.override.yml-all has all examples combined in one file for easy copy/paste.
However, each example also exists in its standalone file as shown below:
host> tree -L 1 compose/ compose/ ├── docker-compose.override.yml-all ├── docker-compose.override.yml-blackfire ├── docker-compose.override.yml-mailhog ├── docker-compose.override.yml-rabbitmq ├── docker-compose.override.yml-solr └── README.md 0 directories, 6 files
In case of MailHog, the file is
compose/docker-compose.override.yml-mailhog. This file
must be copied into the root of the Devilbox git directory.
|What||How and where|
|Example compose file||
|Container IP address||
|Container host name||
|Further configuration||php.ini settings need to be applied per version|
Copy the MailHog Docker Compose overwrite file into the root of the Devilbox git directory.
(It must be at the same level as the default
host> cp compose/docker-compose.override.yml-mailhog docker-compose.override.yml
The next step is to tell PHP that it should use a different mail forwarder.
Let’s assume you are using PHP 7.2.
# Navigate to the PHP ini configuration directory of your chosen version host> cd cfg/php-ini-7.2 # Create and open a new *.ini file host> vi mailhog.ini
Add the following content to the newly created ini file:
[mail function] sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"'
By Default MailHog is using the host port
8025, this can be adjusted in the
HOST_PORT__MAILHOG to .env and customize its value.
Additionally also the MailHog version can be controlled via
The final step is to start the Devilbox with MailHog.
Let’s assume you want to start
host> docker-compose up -d php httpd bind mailhog
For the lazy readers, here are all commands required to get you started. Simply copy and paste the following block into your terminal from the root of your Devilbox git directory:
# Copy compose-override.yml into place cp compose/docker-compose.override.yml-mailhog docker-compose.override.yml # Create php.ini echo "[mail function]" > cfg/php-ini-7.2/mailhog.ini echo "sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr=\"mailhog:1025\"'" >> cfg/php-ini-7.2/mailhog.ini # Create .env variable echo "HOST_PORT_MAILHOG=8025" >> .env echo "MAILHOG_SERVER=latest" >> .env # Start container docker-compose up -d php httpd bind mailhog