Laravel Forge MailHog Install Guide

Email

MailHog is a great email testing client that can enable your clients to see email without your server sending the actual email.

In this guide I show you how to install MailHog on a Laravel Forge Server. This installation was done on Ubuntu 24.04 but should be similar on other Ubuntu versions.

If you want to learn more about MailHog, here is the GitHub repo: https://github.com/mailhog/MailHog

When you're done with the installation, you'll have an SMTP server running on port 1025 and a web-based email client running on port 8025.

Installation

forge
sudo -i
apt -y install golang-go
go install github.com/mailhog/MailHog@latest
~/go/bin/MailHog &

You should see something like the following:

[1] 242137
root@magic:~# 2024/08/07 08:32:34 Using in-memory storage
2024/08/07 08:32:34 [SMTP] Binding to address: 0.0.0.0:1025
[HTTP] Binding to address: 0.0.0.0:8025
2024/08/07 08:32:34 Serving under http://0.0.0.0:8025/
Creating API v1 with WebPath:
Creating API v2 with WebPath:
lang-bash

Next navigate to your Forge server, Network, and add a firewall rule to allow port 8025 if you want to view stuff from the outside. Note: This is a security risk.

Next, install it as a service:

# cat /etc/systemd/system/mailhog.service
[Unit]
Description=MailHog service
[Service]
ExecStart=/root/go/bin/MailHog
[Install]
WantedBy=multi-user.target
lang-bash

Start the service:

service mailhog start
lang-bash

Enable the service on startup:

systemctl enable mailhog
lang-bash

Remember to update your `.env` file to port 8025:

MAIL_PORT=1025
lang-php

Go here to see it running:

https://forge-server-ip:8025