in short - just block all access to port 25
and then whitelist the ip you want mail from
That would bypass your firewall setting of course...
what firewall are you using - be easiest then to tell you the rule
If iptables this should help
SMTP is used to send mail. Sendmail, & Exim (both on cPanel) use the TCP port 25. Following two iptable rule allows incoming SMTP request on port 25 for server IP address 1.2.3.4 (open port 25):
iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 1.2.3.4 --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s 1.2.3.4 --sport 25 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
In order to block port 25 simply use target REJECT instead of ACCEPT in above rules.
And following two iptables rules allows outgoing SMTP server request for server IP address 1.2.3.4:
iptables -A OUTPUT -p tcp -s 1.2.3.4 --sport 1024:65535 -d 0/0 --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp -s 0/0 --sport 25 -d 1.2.3.4 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
this should work as well - but just simply blocks completely
Code:
iptables -A INPUT -s 0.0.0.0 --dport 25 -j DROP