Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Mailcatcher on OSX - works well with macOS Sierra High 10.12.X

05/25/2018: tested with macOS Sierra High 10.12.6

08/04/2020: added @mayesa's suggestion to fix an exception with EventMachine 08/04/2020: tested with macOS Catalina 10.15.5

Install MailCatcher:

brew install ruby
sudo gem install mailcatcher

Run:

mailcatcher &

Or set it up a daemon.

To set it up for PHP: edit php.ini (on OSX brew, /usr/local/etc/php/5.5/conf.d/mailcatcher.ini) and paste the following configuration:

sendmail_path = /usr/bin/env /usr/local/bin/catchmail -f catcher@mailcatcher.me

put any email you want instead of catcher@mailcatcher.me

To test it:

php -r "mail('john.doed@test.fr', 'test', 'test');"

Then, visit the mailcatcher backend : http://localhost:1080

Troubleshoot

  • If you got a 'require': cannot load such file -- i18n/core_ext/string/interpolate (LoadError) exception, run:
sudo gem uninstall i18n
sudo gem install i18n -v 0.6.11
sudo gem install interpolate

(see https://github.com/sj26/mailcatcher/issues/155)

  • If you got an Unable to load the EventMachine C extension exception, run:
sudo gem uninstall mailcatcher eventmachine
sudo gem install mailcatcher
@pitpit

This comment has been minimized.

Copy link
Owner Author

@pitpit pitpit commented Jun 23, 2015

Symfony2 Swiftmailer configuration with mailcatcher:

swiftmailer:
   transport:  smtp
   host:       localhost:1025
   username:   null
   password:   null
   #port:       %mailer_port%
   #encryption: %mailer_encryption%
   #spool:      { type: memory }
@Tantuss

This comment has been minimized.

Copy link

@Tantuss Tantuss commented Oct 14, 2015

In case you get this error (probably because of El Capitan upgrade):
.....
checking for gethrtime()... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:116:10: fatal error: 'openssl/ssl.h' file not found

include <openssl/ssl.h>

     ^

1 error generated.
make: *** [binder.o] Error 1

make failed, exit code 2

Install it like this:
gem install mailcatcher -- --with-cppflags=-I/usr/local/opt/openssl/include

@irvins

This comment has been minimized.

Copy link

@irvins irvins commented Oct 26, 2015

Thank you Tantuss , that was exactly the problem i was running into.

@blanco217

This comment has been minimized.

Copy link

@blanco217 blanco217 commented Oct 29, 2015

Thanks Tantuss that helped with my problem

@kirkgale

This comment has been minimized.

Copy link

@kirkgale kirkgale commented Dec 16, 2015

@Tantuss you rock, that fixed it for me as well.

@juukie

This comment has been minimized.

Copy link

@juukie juukie commented May 25, 2016

Not sure why but I had to copy mailcatcher and catchmail from /usr/local/Cellar/ruby/2.0.0-p247/bin to /usr/local/opt/bin to get it working. On my other iMac I did not have to copy the files. Probably the ruby version did it (other iMac had version 2.3.1).

@FlorinMotoc

This comment has been minimized.

Copy link

@FlorinMotoc FlorinMotoc commented Oct 27, 2016

On macOS Sierra (only sudo gem install mailcatcher run, without brew ruby), correct line is:

sendmail_path = /usr/bin/env /usr/local/bin/catchmail -f catcher@mailcatcher.me

It didn't worked for me any other way.

@rupokify

This comment has been minimized.

Copy link

@rupokify rupokify commented Dec 14, 2016

On macOS Sierra (only sudo gem install mailcatcher run, without brew ruby), correct line is:

sendmail_path = /usr/bin/env /usr/local/bin/catchmail -f catcher@mailcatcher.me

It didn't worked for me any other way.

@FlorinMotoc You just saved my day buddy! Thanks a ton.

@rordi

This comment has been minimized.

Copy link

@rordi rordi commented Jan 3, 2017

To use with CakePHP 3, adjust config/app.php:

 'EmailTransport' => [
	'mailcatcher' => [
		'className' => 'Smtp',
		'host' => 'localhost',
		'port' => 1025,
	],
 ],

and

'Email' => [
    'default' => [
        'transport' => 'mailcatcher',
        'from' => 'anything@here.com',
        'charset' => 'utf-8',
        'headerCharset' => 'utf-8',
    ],
],
@ahules

This comment has been minimized.

Copy link

@ahules ahules commented Mar 25, 2017

Hello, I installed mailcatcher using command:
sudo gem install mailcatcher
Then create /mailcatcher.ini
and put there "sendmail_path = /usr/bin/env catchmail -f catcher@mailcatcher.me"

But "mailcatcher" catch mail only when I send email from cli.
Like this: php -r "mail('john.doed@test.fr', 'test', 'test');"
When i try send email via script from browser mail function returns false.

Can you help how to fix this behavior?

@jeremiahsmall

This comment has been minimized.

Copy link

@jeremiahsmall jeremiahsmall commented Jun 6, 2017

Perfect solution for testing a legacy app with the built in php server. Thx!

@matthewhaworth

This comment has been minimized.

Copy link

@matthewhaworth matthewhaworth commented Jan 11, 2018

Not sure if anyone had an issue on Macs, but I had a problem on Mac OS Sierra. I changed

sendmail_path = /usr/bin/env catchmail -f catcher@mailcatcher.me
to
sendmail_path = /usr/bin/env /usr/local/bin/catchmail -f catcher@mailcatcher.me

and it worked!

@reillo

This comment has been minimized.

Copy link

@reillo reillo commented May 3, 2018

If you're having issue on CLI or Unit testing. Make sure that
php -i | grep sendmail_path returns the correct configuration of mailcathcer.

@ahmadmayahi

This comment has been minimized.

Copy link

@ahmadmayahi ahmadmayahi commented Oct 17, 2018

For Symfony 4+ usage, modify .env file as follows:
MAILER_URL=smtp://localhost:1025

@ernestjumbe

This comment has been minimized.

Copy link

@ernestjumbe ernestjumbe commented Feb 9, 2020

Tanks so much for this. I had almost given up.

@chrisVdd

This comment has been minimized.

Copy link

@chrisVdd chrisVdd commented Apr 14, 2020

For Symfony 4+ usage, modify .env file as follows:
MAILER_URL=smtp://localhost:1025

And start from Symfony 4.3, if you use the new Symfony Mailer component:

MAILER_DSN=smtp://localhost:1025

@radrr

This comment has been minimized.

Copy link

@radrr radrr commented May 27, 2020

Hi i have installed mailcatcher using the standard 'brew' and 'gem' approach described above. During the past year everything worked fine, but quite recently (using MacOS Catalina 10.15.4) i started getting following error message and i'm unable to start mailcatcher:

Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby' Traceback (most recent call last): 10: from /usr/local/bin/mailcatcher:23:in '<main>' 9: from /usr/local/bin/mailcatcher:23:in 'load' 8: from /Library/Ruby/Gems/2.6.0/gems/mailcatcher-0.7.1/bin/mailcatcher:3:in '<top (required)>' 7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in 'require' 6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in 'require' 5: from /Library/Ruby/Gems/2.6.0/gems/mailcatcher-0.7.1/lib/mail_catcher.rb:15:in '<top (required)>' 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in 'require' 3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in 'require' 2: from /Library/Ruby/Gems/2.6.0/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:8:in '<top (required)>' 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in 'require' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in 'require': dlopen(/Library/Ruby/Gems/2.6.0/gems/eventmachine-1.0.9.1/lib/rubyeventmachine.bundle, 0x0009): dependent dylib '/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib' not found for '/Library/Ruby/Gems/2.6.0/gems/eventmachine-1.0.9.1/lib/rubyeventmachine.bundle' - /Library/Ruby/Gems/2.6.0/gems/eventmachine-1.0.9.1/lib/rubyeventmachine.bundle (LoadError)

@mayesa

This comment has been minimized.

Copy link

@mayesa mayesa commented Jun 1, 2020

Same here

@mayesa

This comment has been minimized.

Copy link

@mayesa mayesa commented Jun 1, 2020

@radrr I fixed the above error by running

sudo gem uninstall mailcatcher eventmachine
sudo gem install mailcatcher
@radrr

This comment has been minimized.

Copy link

@radrr radrr commented Jun 1, 2020

@radrr I fixed the above error by running

sudo gem uninstall mailcatcher eventmachine
sudo gem install mailcatcher

Hey Mayesa, you have solved the issue, mailcatcher now runs again as a charm :) many thanks!

@blockerdude

This comment has been minimized.

Copy link

@blockerdude blockerdude commented Jul 24, 2020

Can also confirm that @mayesa's solution works.

@yojeek

This comment has been minimized.

Copy link

@yojeek yojeek commented Nov 4, 2020

To fix build issues with Catalina:

gem install thin -v 1.5.1 -- --with-cflags="-Wno-error=implicit-function-declaration"
gem install mailcatcher

source

@Jliv316

This comment has been minimized.

Copy link

@Jliv316 Jliv316 commented Mar 2, 2021

@mayesa's solution works

@sylow

This comment has been minimized.

Copy link

@sylow sylow commented Mar 18, 2021

gem install thin -v 1.5.1 -- --with-cflags="-Wno-error=implicit-function-declaration"

This is what worked for me on Mac M1. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment