Policy based routing
Solution 1:
Configure IPROUTE2
echo "4 sendmail" >> /etc/iproute2/rt_tables
ip route add 121.XXX.XX.XXX/MASK dev eth0 src 121.XXX.XX.XXX table sendmail
ip route add 192.168.1.XXX/24 dev eth2 table sendmail
ip route add default via GATEWAY1 table sendmail
ip ru add from 121.XXX.XX.XXX lookup sendmail
ip ru add fwmark 2 table sendmail
ip route flush cache
Configure IPTABLES
iptables -t mangle -I OUTPUT -p tcp --dport 25 -j MARK --set-mark 0x2
iptables -t mangle -I PREROUTING -i eth2 -p tcp --dport 25 -j MARK --set-mark 0x2
iptables -t nat -I POSTROUTING -s 192.168.1.XXX/24 -o eth0 -j SNAT --to-source 121.XXX.XX.XXX