Skip to content

Instantly share code, notes, and snippets.

@rumur
Last active September 16, 2020 18:21
Show Gist options
  • Save rumur/9f8cce2bb12e004b68880ac12987497c to your computer and use it in GitHub Desktop.
Save rumur/9f8cce2bb12e004b68880ac12987497c to your computer and use it in GitHub Desktop.
Install the mailcatcher on macOS Mohave 10.14.2 without `sudo`

Install the mailcatcher on macOS Mohave 10.14.2 without sudo

1. Open the terminal or iTerm2

2. Run the command and wait for a while

$ gem install --user-install mailcatcher

3. Add Gem's bin directory to your path, open your ~/.zshrc or ~/.bash_profile with your editor

GEM_PATH=$HOME/.gem/ruby/2.3.0/bin

export PATH="$GEM_PATH:$PATH"

4. ⚠ Reopen the terminal to make new $PATH variable works.

5. Create the ext-mailcatcher.ini for your php version

$ touch /usr/local/etc/php/7.1/conf.d/ext-mailcatcher.ini

6. Add a configuration to this file

$ echo sendmail_path = /usr/bin/env /Users/$(whoami)/.gem/ruby/2.3.0/bin/catchmail -f local@catch > /usr/local/etc/php/7.1/conf.d/ext-mailcatcher.ini

7. Restart the php via brew

$ brew services restart php

7.1 You can also restart valet if you're using one.

$ valet restart

8. Run the mailcatcher itself in terminal

$ mailcatcher

9. Run the command for test

$ php -r 'mail("test@local.test", "Caught by mailcatcher", "Hi there!");'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment