Search Our Database
Firewall rules for script mailer with Gmail SMTP
Introduction
Most of the Linux servers at IP ServerOne are implemented with strict firewall rules, particularly restricting outbound ports for user Apache. For users utilizing scripting mailers to send emails via Gmail SMTP, the system administrator must add specific firewall rules to allow outbound traffic on ports 465 and 587, which are required for Gmail SMTP.
This guide will walk you through the steps to add these firewall rules to your server.
Prerequisites
- Root access to the server or root privileges.
- Basic knowledge of SSH and CLI commands.
Step-by-Step Guide
Step 1: SSH into the server
- Use SSH to access the server. If you are not logged in as root, type the following command to switch to the root user:
sudo -i
Step 2: Edit the firewall rules
- Open the firewall rules for editing by entering the following command:
vi /sbin/fwup
Step 3: Add the necessary firewall rules
- Search for the firewall rules associated with –uid-owner apache .
- Under this section, add the following rules to allow traffic on ports 465 and 587 for Gmail SMTP:
/sbin/iptables -A OUTPUT -p tcp --dport 465 -m owner --uid-owner apache -j ACCEPT /sbin/iptables -A OUTPUT -p tcp --dport 587 -m owner --uid-owner apache -j ACCEPT
Step 4: Apply the changes
- To apply the changes, rerun the firewall by executing the following command:
/sbin/fwup &
Important Note: Misconfiguring the firewall may cause services or applications on the server to experience issues with incoming or outgoing traffic. Ensure that you carefully follow the steps to avoid any disruptions.
Conclusion
By following the steps outlined above, you will successfully open ports 465 and 587 for outgoing traffic, allowing the use of Gmail SMTP.
For additional assistance or if you encounter any issues, please contact our support team at support@ipserverone.com.