Install mailhog on ubuntu 18

MailHog is a tool used by developers for testing emails.

step 1

apt-get update
apt-get upgrade

step 2

apt-get -y install golang-go
pwd
/root

step 3 -Now Download and configure MailHog

git clone https://github.com/mailhog/MailHog.git
cd MailHog/
mkdir gocode
cd gocode/
vi ~/.profile
export GOPATH=/root/MailHog/gocode 
//save & exit
source ~/.profile
go get github.com/mailhog/MailHog
cp -Rap bin/MailHog /usr/local/bin/mailhog
mailhog bcrypt P@ssw0rd@123
//$2a$04$Cqvq9D24HXeRtLR9DdgOKO5y3DHqpTm9dyPmX0laEP7Nv1r0Vq2Zy
cd ../docs/
vi example-auth
support:$2a$04$Cqvq9D24HXeRtLR9DdgOKO5y3DHqpTm9dyPmX0laEP7Nv1r0Vq2Zy
//username and encrypted password

step 4 – Starting MailHog automatically by adding a systemd service

cd ~ 
vi /etc/systemd/system/mailhog.service
[Unit]
Description=Start MailHog Service
After=network.target


[Service]
Type=forking
WorkingDirectory=/root/MailHog
ExecStart=/bin/sh -c "cd /root/MailHog; nohup mailhog -auth-file=/root/MailHog/docs/example-auth >> /var/log/mailhog.log 2>&1 &"
User=root
Group=root


[Install]
WantedBy=multi-user.target

step 5

systemctl daemon-reload
systemctl enable mailhog

//Created symlink from /etc/systemd/system/multi-user.target.wants/mailhog.service to /etc/systemd/system/mailhog.service.

systemctl start mailhog
systemctl status mailhog
  • Now check it from browser:

http://165.22.138.238:8025  (localhost IP:default_port)

Facebook Comments

You may also like