Joeri Verdeyen bio photo

Joeri Verdeyen

Web-engineer, cyclist, Nespresso lover, Strava pusher.

Twitter LinkedIn Instagram Github Stackoverflow Strava

Configure MailCatcher for Symfony2

Using MailCatcher in combination with Symfony2 on your development machine will make it easy to check the e-mails you are sending out.

What is MailCatcher

MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface.

Install MailCatcher

Install MailCatcher dependecies, sqlite and ruby.

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

Install the MailCatcher Ruby gem

sudo gem install mailcatcher

Start MailCatcher

mailcatcher --foreground --http-ip=

This will start up MailCatcher, but only when you trigger this command. I thinks it’s more convenient to start MailCatcher with Upstart.

Create an upstart script

Create and edit file /etc/init/mailcatcher.conf.

description "Mailcatcher"

start on runlevel [2345]
stop on runlevel [!2345]

pre-start script

bash << "EOF"
  mkdir -p /var/log/mailcatcher
  chown -R vagrant /var/log/mailcatcher

end script

exec /usr/bin/env $(which mailcatcher) --foreground --http-ip= &>>/var/log/mailcatcher/mailcatcher.log

After configuring this upstart config file, you’re able to use the following set of commands:

sudo service mailcatcher status
sudo service mailcatcher start
sudo service mailcatcher restart
sudo service mailcatcher stop

Run sudo service mailcatcher start after that you should be able to visit the web interface on (replace with the ip of your development machine).

Configure Symfony2

In order to re-route all mail traffic from Swiftmailer to MailCatcher, you should adjust your config_dev.yml file with the following settings:

    transport: smtp
    host: 'localhost'
    port: 1025
    username: null
    password: null

And Symfony2 profiler’ mail item?

Yes, that’s still working and for me personal this is a much faster way to check and validate emails and their content.

Thanks for reading

Feel free to leave a comment if you have remarks or like this post