By Niomar
Greetings,
I recently discovered droplet hasn’t been sending out emails from a Contact Us page on my Wordpress website. I confirmed outgoing port 25 wasn’t blocked by the firewall, so submitted a ticket to Support. Here was their response:
I am sorry to hear that you are facing issue with the SMTP on the Droplet. It looks like you trying to use Floating IP address for the SMTP.
In order to curb abuse, sending mail through SMTP is not supported with Floating IPs. You can use the static Droplet IP address for the SMTP.
Is there a single command I can run on my Ubuntu 18.04 server to only route my outgoing port 25 traffic through my static IP?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @Niomar,
You can do this with iptables, which is part of the Linux kernel. On your droplet, run:
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 25 -j DNAT --to XXX.XXX.XX.XX:25
iptables -A INPUT -p tcp -m state --state NEW --dport 25 -i eth0 -j ACCEPT
where XXX.XXX.XX.XX is the IP address of the server you want to forward to. You may need to change “eth0” to whatever your device is called and the IP on it.This can be checked by running the command
ip a
The first rule sets up the forwarding, and the second rule makes sure that connections to port 25 are accepted on the droplet the application is on.
Disclaimer: Please make sure to backup your droplet or at least your IPTables so that if this doesn’t work you can revert the changes!!
Regards, KDSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.