Enable and configure MailHog
Enable and configure MailHog
MailHog catches outgoing application email during development and shows it in a browser UI, avoiding accidental delivery to real recipients.
How it works
Devilbox keeps optional integrations as override snippets in the compose/
directory. To enable MailHog, copy its snippet into the project root as
docker-compose.override.yml, then start the stack.
Enable
cp compose/docker-compose.override.yml-mailhog docker-compose.override.yml./dvl.sh upConfiguration
The snippet defines service mailhog with image
${MAILHOG_IMAGE:-mailhog/mailhog}:${MAILHOG_SERVER:-latest}, hostname
mailhog, IP 172.16.238.252, and UI port
${HOST_PORT_MAILHOG:-8025}:8025. It does not mount volumes.
| Variable | Default | Purpose |
|---|---|---|
MAILHOG_IMAGE | mailhog/mailhog | MailHog image repository. |
MAILHOG_SERVER | latest | MailHog image tag. |
HOST_PORT_MAILHOG | 8025 | Host port for the MailHog Web UI. |
Configure PHP to send mail to MailHog’s SMTP listener:
[mail function]sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"'Place that in the php.ini directory for your selected PHP version, for example
cfg/php-ini-8.3/mailhog.ini.
Usage
Open the mailbox UI:
open http://localhost:8025Send a test email from inside PHP:
Point an application SMTP client at host mailhog, port 1025, without TLS or
authentication.
Disable
./dvl.sh downrm docker-compose.override.yml./dvl.sh upRemove the MailHog php.ini file if PHP should return to its previous mail transport.
Troubleshooting
- If messages do not appear, confirm PHP is using the php.ini file for the active PHP version.
- If the UI does not load, check whether another process already uses host port
8025and adjustHOST_PORT_MAILHOG. - If an app uses SMTP directly, verify it points to
mailhog:1025from inside the Docker network, notlocalhost.