Last active
February 25, 2022 16:40
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 [email protected]" | 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