Skip to content

Instantly share code, notes, and snippets.

@munkiepus
Last active February 25, 2022 16:40
Show Gist options
  • Save munkiepus/272e07b9dd2db57c7ecb3d79faf3cf18 to your computer and use it in GitHub Desktop.
Save munkiepus/272e07b9dd2db57c7ecb3d79faf3cf18 to your computer and use it in GitHub Desktop.
install mailcatcher with systemd init script on ubuntu 18.04 and catch all sendmail
#!/bin/bash
echo "-- installing mailcatcher -- "
apt-get install ruby ruby-dev ruby-all-dev sqlite3 libsqlite3-dev -y
gem install mailcatcher
echo '[Unit]
Description = MailCatcher
After=network.target
After=systemd-user-sessions.service
[Service]
Type=simple
Restart=on-failure
User=vagrant
ExecStart=/usr/local/bin/mailcatcher --foreground --smtp-ip 0.0.0.0 --ip 0.0.0.0
[Install]
WantedBy=multi-user.target
' >> /etc/systemd/system/mailcatcher.service
chmod 744 /etc/systemd/system/mailcatcher.service
systemctl enable mailcatcher
service mailcatcher start
service mailcatcher status
# use mailcatcher for all php mail sent with sendmail
echo "sendmail_path = /usr/bin/env $(which catchmail) -f test@local.dev" | sudo tee /etc/php/mods-available/mailcatcher.ini
sudo phpenmod mailcatcher
sudo service php7.2-fpm restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment