Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mailcatcher installation script for Ubuntu 16.04 (14.04 commands commented out)
#!/bin/bash
# Install dependencies
# older ubuntus
#apt-get install build-essential libsqlite3-dev ruby1.9.1-dev
# xenial
apt install build-essential libsqlite3-dev ruby-dev
# Install the gem
gem install mailcatcher --no-ri --no-rdoc
# Make it start on boot
echo "@reboot root $(which mailcatcher) --ip=0.0.0.0" >> /etc/crontab
update-rc.d cron defaults
# Make php use it to send mail
# older ubuntus
#echo "sendmail_path = /usr/bin/env $(which catchmail) -f 'www-data@localhost'" >> /etc/php5/mods-available/mailcatcher.ini
# xenial
echo "sendmail_path = /usr/bin/env $(which catchmail) -f 'www-data@localhost'" >> /etc/php/7.0/mods-available/mailcatcher.ini
# Notify php mod manager (5.5+)
# older ubuntus
#php5enmod mailcatcher
# xenial
phpenmod mailcatcher
# Start it now
/usr/bin/env $(which mailcatcher) --ip=0.0.0.0
@johi

This comment has been minimized.

Copy link

commented Sep 9, 2016

Thanks a bunch, you just saved me a lot of time :-)

@jayshields

This comment has been minimized.

Copy link

commented Dec 2, 2016

Just tried this. Couple of hints for people struggling:

  • You'll need to restart Apache after enabling any PHP modules (eg. after phpenmod mailcatcher). Use sudo /etc/init.d/apache2 restart for this.
  • The sendmail_path line in the mailcatcher.ini didn't work for me. PHP was reporting the sendmail_path to be set as /usr/bin/env $(which catchmail rather than the full correct string. This worked instead: sendmail_path = /usr/bin/env catchmail -f www-data@localhost
  • Piping the echo statements into the files didn't work (permissions issues). I had to do that manually with sudo.
@jonathanbossenger

This comment has been minimized.

Copy link

commented Apr 12, 2017

Make sure you switch to the root user to perform these commands

sudo su root

@kwoxer

This comment has been minimized.

Copy link

commented May 31, 2017

Great, working properly. Thanks.

@andreasneuber

This comment has been minimized.

Copy link

commented Oct 9, 2017

I confirm best you switch to root user.
In case mailcatcher gem install gets stuck at ri documentation - gem install mailcatcher --no-ri --no-rdoc solved the issue for me.

@lrasmus

This comment has been minimized.

Copy link

commented Oct 30, 2017

Works like a charm, thanks!

@aovchenkov

This comment has been minimized.

Copy link

commented Apr 10, 2018

Thanks a lot!!

@shark0der

This comment has been minimized.

Copy link
Owner Author

commented Jul 3, 2018

@andreasneuber great tip, thanks!

@ismai1

This comment has been minimized.

Copy link

commented Oct 7, 2018

thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.