Setup MailHog with Laravel Valet


Before we begin, you need to have Homebrew installed. If you don't, visit for instructions on how to get it installed.

If you're not using Laravel Valet, you can skip the last section of this tutorial and use the localhost / domain instead.

Installing MailHog

To install MailHog, run the follow commands in your terminal:

brew install mailhog

This command will install MailHog on your system, but won't enable the service.

To enable the service, run the command below:

brew services start mailhog

This will instruct Homebrew to setup a background service so that MailHog is always running on your machine. You won't need to manually start anything, as long as Homebrew is running.

Now, you can visit in a browser and you should be greeted with the MailHog application:

MailHog image

Configuring your Laravel application

To get MailHog working with your Laravel application, update the following keys in your .env file:


The reason the ports are different to the MailHog UI is that the SMTP server is running on port 1025, where as the HTTP server is running on 8025.

If you send an email from your Laravel application now, you will see it pop up in the MailHog interface. You can use the code snippet below inside of Laravel Tinker to test:

Mail::raw('MailHog', fn ($message) => $message->to('')->from(''));

Setting up a .test domain

Laravel Valet makes this process super easy. All you need to do is run the following command in your terminal:

valet proxy mailhog.test

This command will create an Nginx configuration file for the domain mailhog.test, proxying all requests to that domain through to the MailHog HTTP server.

It will also setup an SSL certificate, just like valet secure does for your normal Laravel sites.

You might also enjoy...

Found this article useful? Share on Twitter!