Skip to content

Instantly share code, notes, and snippets.

@pitpit
Last active November 21, 2022 04:45
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save pitpit/78fc6b34b1b564c86d80 to your computer and use it in GitHub Desktop.
Save pitpit/78fc6b34b1b564c86d80 to your computer and use it in GitHub Desktop.
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 sj26/mailcatcher#155)

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

macOS Monterey work:

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

@laurentfontaine1967
Copy link

Got this with my macbook air on Monterey:

ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
macbookair@macbooks-air ~ %

@sunwooz
Copy link

sunwooz commented Nov 21, 2022

To fix build issues with Catalina:

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

source

Worked on Monterey, thanks!

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