My Profile Photo

Ionut Gavrilut

DevOps Enthusiast | Linux System Administrator | Certified Jenkins Engineer

Redirect Outgoing Mails to MailHog with iptables

If you want to redirect all outgoing mails to MailHog, using your firewall:

iptables -t nat -A OUTPUT -p tcp -d a.b.c.d --dport 25 -j DNAT --to-destination

assuming MailHog is installed locally.

This need to be saved if you want to persist:

iptables-save > /etc/sysconfig/iptables

on CentOS