This is a Ruby gem which collects outgoing email messages from your app and displays them in a webmail portal.
The general install directions are provided on the site, however there are several variances with my own developement environment which have proved a challenge.
If you are using RVM it might be recommended to install this gem globally for all environments.
rvm @global do gem install mailcatcher
If you are running on a Mac and have installed an updated version of PHP using Homebrew, your php.ini
file is most likely not in the same location as with the default Mac installation. To find where your
current configuration file is located run the following command.
php --ini
For example my configuration path is /usr/local/etc/php/7.0/php.ini
not the default Mac's PHP path /etc/php.ini
.
Edit your php.ini like the following. The main gotcha with this is swapping the port number. The default is 25
, but mailcatcher listens on 1025
by default. Note that depending how you installed mailcatcher, whether or not
you are using RVM, may change the exact path to the mailcatcher executable.
smtp_port = 1025
sendmail_path = /usr/bin/env catchmail --smtp-port 1025 -f me@localhost
You will need to restart your local webserver, Apache or NGINX, in order for your changes to take affect.
To check your configuration is loaded make an info.php file in your web root and add the following PHP code to output the PHP info.
<?php
phpinfo();
Load this file up in your browser and search for the SMTP settings. These lines should match the
settings you entered in the php.ini
file.
Now you are ready to run mailcatcher with the following. This will start the webmail portal. The webmail URL will also be output by this command.
mailcatcher
There is the option to clear and quit mailcatcher from within the webmail interface.