Biplob Hossain

How to Install and Use MailHog on macOS (Perfect for Laravel Herd, Concrete CMS, or Any PHP App)

September 30, 2025 | by biplob.ice

mailhog_biplob.me

When developing email features locally, using PHP’s mail() or even SMTP to real addresses can be unreliable or unsafe. You might accidentally spam your real users, hit Gmail’s spam filters, or find yourself debugging with no logs. Enter MailHog — a local email testing tool that captures emails in a web interface and prevents them from going out to real inboxes.

What is MailHog?

MailHog is a lightweight SMTP server designed for development and testing. It captures all outbound emails and shows them in a clean, local web interface. No real email gets sent — perfect for previewing and debugging!

Step 1: Install MailHog on macOS

You can install it using Homebrew:

brew install mailhog

That’s it — it will download the binary and place it in your path.

Step 2: Run MailHog

To start MailHog manually:

mailhog

By default, it runs:

  • SMTP server on port 1025
  • Web UI on port 8025

Visit:

http://localhost:8025

You’ll see a local inbox where all sent emails will appear instantly.

Step 3: Configure Your App to Use MailHog

Whether you’re using Laravel, Concrete CMS, or vanilla PHP — you just need to point your mail configuration to use:

SettingValue
SMTP Host127.0.0.1
SMTP Port1025
Encryptionnone (or blank)
Username/Passleave blank

Example: Laravel .env

MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME="My Local App"

Example: Concrete CMS SMTP Settings

In the dashboard:

System & Settings → Email → SMTP

Set:

  • SMTP Server: 127.0.0.1
  • Port: 1025
  • Encryption: none
  • Username/Password: blank

Save, then send a test email. It should appear instantly at http://localhost:8025.

Optional: Run MailHog Automatically

To keep MailHog running in the background, you can use brew services:

brew services start mailhog

It’ll auto-start with your system.

To stop it later:

brew services stop mailhog

Why Use MailHog?

✅ Captures all emails sent locally
✅ Prevents real delivery to users
✅ Shows HTML and plain text versions
✅ Lets you inspect headers, raw content, and attachments
✅ Super easy to install and use

Bonus: Test from PHP or Laravel

use Illuminate\Support\Facades\Mail;

Mail::raw('Test message', function ($message) {
    $message->to('test@example.com')->subject('Hello from MailHog');
});

Visit http://localhost:8025 — your message will be there.

Troubleshooting

IssueFix
Mail not showing in MailHogMake sure SMTP port is set to 1025
Laravel still using mail()Set MAIL_MAILER=smtp
Port already in useRun MailHog on a different port with -smtp-bind-addr :2025
Using PHP mail()MailHog won’t work unless you configure Postfix to forward to it (use SMTP instead)

Final Thoughts

MailHog is the must-have tool for local email development. Whether you’re building a Laravel app, a Concrete CMS site, or working on raw PHP, using MailHog helps you catch issues before they hit production — with zero spam and 100% confidence.

TL;DR

brew install mailhog
mailhog
# Visit: http://localhost:8025
# Configure your app to use SMTP → 127.0.0.1:1025

Let your emails fly — but only locally 🛫📥

RELATED POSTS

View all

view all