Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Change the SMTP Port on a VPS or Dedicated Server

This guide shows how to make your mail server listen on another port. It needs root access.

Web Hosting2 min read9 steps1 screenshots
Note: You need root access. Root is the all-powerful admin user on a server. VPS and dedicated server customers have it.

What is an SMTP port?

SMTP is the system that sends email. A port is like a numbered door on a server. Each service uses its own door. SMTP normally uses port 25. Some internet providers block port 25, so people open another door, such as 587 or 2525.

Before you start

A wrong change can stop your email from working. Take a backup of the config file first. Also keep one SSH session open while you test. SSH is a safe way to control a server by typing commands.

Steps for Exim

Exim is a common mail program on cPanel servers. Other systems differ, so check which mail program you use.

  1. Log in to your server over SSH as root.
  2. Back up the file:
cp /etc/exim.conf /etc/exim.conf.bak

This makes a safe copy named exim.conf.bak.

  1. If you use WHM, open Service Configuration and then Exim Configuration Manager. Look for the option that sets extra ports, often called Port for SMTP to listen on. Add your new port, for example 2525.
    Change SMTP Port
  2. Save the setting. WHM rebuilds the config and restarts Exim for you.

Steps for Postfix

  1. Open the file /etc/postfix/master.cf in an editor such as nano.
  2. Find the line starting with smtp inet.
  3. Add a new line using your port number, for example 2525 inet n - n - - smtpd.
  4. Save the file.
  5. Restart Postfix:
systemctl restart postfix

This stops and starts the mail program so it reads the new setting.

Open the port in the firewall

A firewall blocks unwanted doors. Allow your new port. For example, with CSF:

csf -a 0.0.0.0/0 -p 2525

Or edit the allowed incoming ports list in the CSF config. With firewalld:

firewall-cmd --permanent --add-port=2525/tcp
firewall-cmd --reload

Test it

telnet localhost 2525

If you see a line starting with 220, the port works.

Quick recap

  • Port 25 is the default SMTP port. Some providers block it.
  • Back up the config before editing.
  • Add the new port in Exim or Postfix.
  • Restart the mail service.
  • Allow the port in the firewall, then test.