Skip to content

Instantly share code, notes, and snippets.

@erral
Forked from eliasby/Mailhog Bash Script (systemd)
Last active January 16, 2023 07:44
Show Gist options
  • Save erral/c7ff9b6b40aa75b0f10a701ec9fc9e4c to your computer and use it in GitHub Desktop.
Save erral/c7ff9b6b40aa75b0f10a701ec9fc9e4c to your computer and use it in GitHub Desktop.
Mailhog setup with systemd. Copy and paste this to a terminal in your computer. It will start a MailHog server listening on port 25 and a web based interface listening on port 8025
#!/usr/bin/env bash
echo ">>> Installing Mailhog"
# Download binary from github
sudo wget --quiet -O /usr/local/bin/mailhog https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64
# Make it executable
sudo chmod +x /usr/local/bin/mailhog
# Make it start on reboot
sudo tee /etc/systemd/system/mailhog.service <<EOL
[Unit]
Description=MailHog Service
After=network.service vagrant.mount
[Service]
Type=simple
ExecStart=/usr/bin/env /usr/local/bin/mailhog -smtp-bind-addr :25 -storage maildir > /dev/null 2>&1 &
[Install]
WantedBy=multi-user.target
EOL
# Start on reboot
sudo systemctl enable mailhog
# Start background service now
sudo systemctl start mailhog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment