Using mailcatcher with Homestead

I was recently made aware of mailcatcher, an awesome little tool to allow devs to run a mock SMTP server on their machine and direct their apps mail to it when developing / testing.

At VentureCraft we’re using Homestead to organize and keep dev environments in sync which is awesome, but caused some problems when we wanted to set mail settings in a mail.php config file when running in Homestead, since if I had mailcatcher running on my local machine I needed to point the mail config there, which would obviously cause issues for other developers working offset.

Here’s what we came up with.

First, I adding the following to my file:

sudo apt-get install ruby1.9.1-dev -y
sudo apt-get install libsqlite3-dev
sudo gem install mailcatcher

Then I have to SSH in and run “mailcatcher –ip=″

If I try add that line to the file, it complains that port 1025 is already in use for some reason.

( being the IP set in homestead.rb)

This does increase the boot up time quite a bit, which is annoying, but it works.

I can now hit to view the mail, and send to on port 1025 in my mail.php config file.

  • al8anp

    – is called in a loop, which is probably why mailcatcher complains that port 1025 is in use
    – this excellent PR on laravel/homestead should help:
    It allows you to run any command during provisionning, so you can run mailcatcher from there
    Thanks for the post, it helped a lot.

    • Chris Duell

      Quite right, I’ve made a lot of updates to our setup, including ensuring that only sets up what it needs for the specific project, no more, I then added a new file to run final setup tasks like firing up mailcatcher

      You can see our full setup here: