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 serve.sh 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=192.168.33.10″

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

(192.168.33.10 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 http://192.168.33.10:1080/ to view the mail, and send to 192.168.33.10 on port 1025 in my mail.php config file.

  • al8anp

    Hi,
    – serve.sh 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:
    https://github.com/laravel/homestead/pull/76
    It allows you to run any command during provisionning, so you can run mailcatcher from there
    Thanks for the post, it helped a lot.

    • http://chrisduell.com/ Chris Duell

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

      You can see our full setup here: https://github.com/duellsy/homestead