MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface. Run mailcatcher, set your favourite app to deliver to smtp://127.0.0.1:1025 instead of your default SMTP server, then check out http://127.0.0.1:1080 to see the mail that's arrived so far.
I found MailCatcher to be incredibly useful while testing emails in my Laravel 4 applications. While setting
Mail::pretend() can be useful, it only gives you limited information about the message your application attempted to send.
Jeffrey Way has a great lesson on testing your emails with MailCatcher at Laracasts in which he discusses the installation of MailCatcher. However, Laravel Homestead is not prepared to handle the quick and easy installation outlined in Way's video.
After some research, I was able to successfully get MailCatcher running in my Laravel Homestead machine. Here's how!
// Install MailCatcher $ sudo apt-get install ruby1.9.1-dev libsqlite3-dev $ sudo gem install mailcatcher
Next, you'll need to run MailCatcher. My Homestead IP is
192.168.50.10, so I'll be using that one. Most Laravel Homestead installs will use
192.168.10.10, but this is customizable in
// Run Mailcatcher $ mailcatcher --ip 192.168.50.10
You can now access MailCatcher in your browser at
To use MailCatcher in your Laravel application, you'll have to edit the configuration in
/app/config/mail.php. However, it's recommended to copy this file to
/app/config/local/mail.php so that the configuration only applies to your local development environment. Here's my
mail.php config file.
<?php return [ 'driver' => 'smtp', 'host' => '192.168.50.10', 'port' => 1025, 'from' => array('address' => 'firstname.lastname@example.org', 'name' => 'Test Email Sender'), 'encryption' => false, 'username' => null, 'password' => null, ];
It's important that you set the
1025, and you disable
Go ahead and send an email from Laravel, and see it appear in the MailCatcher UI!