Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Mailhog with a Forge recipe
#run as root
apt-get install golang-go -yqq
mkdir gocode
export GOPATH=$HOME/gocode
go get github.com/mailhog/MailHog
go get github.com/mailhog/mhsendmail
cp /root/gocode/bin/MailHog /usr/local/bin/mailhog
cp /root/gocode/bin/mhsendmail /usr/local/bin/mhsendmail
cat >/etc/systemd/system/mailhog.service <<EOL
[Unit]
Description=MailHog service
[Service]
ExecStart=/usr/local/bin/mailhog
[Install]
WantedBy=multi-user.target
EOL
cp /etc/php/7.1/cli/php.ini /etc/php/7.1/cli/php.ini.bak
cp /etc/php/7.1/fpm/php.ini /etc/php/7.1/fpm/php.ini.bak
sed -i 's/^\;sendmail_path =$/sendmail_path = \/usr\/local\/bin\/mhsendmail/' /etc/php/7.1/cli/php.ini
sed -i 's/^\;sendmail_path =$/sendmail_path = \/usr\/local\/bin\/mhsendmail/' /etc/php/7.1/fpm/php.ini
systemctl restart nginx
systemctl restart php7.1-fpm
systemctl start mailhog
systemctl enable mailhog
php -r "\$from = \$to = 'example@gmail.com'; \$x = mail(\$to, 'subject'.time(), 'Hello from Forge recipes!', 'From: '. \$from); var_dump(\$x);"
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.