smtp
Block or unblock all outgoing mail connections on port 25 (spam protection), or turn on an extra Postfix SMTP port 26
- Command:
/go/smtp - Category: Mail
- Arguments:
block,unblock,enable(or26), or anything else to turn port 26 off - Output: One status line for
blockandunblock. Nothing for the port 26 options. - Last updated: 2026-11-21
On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also
Overview
/go/smtp manages SMTP port 25 on the server. It does two separate jobs:
- Outgoing port 25: block or unblock.
blockstops the server from connecting to other servers on port 25, which stops a spam run quickly.unblockremoves that rule. The alert text is written for use by GoAdmio's own spam detection, but you can run it by hand. - Incoming port 26: turn it on or off.
enablemakes Postfix also accept mail on port 26. Any other value turns that off again.
[!WARNING]
blockcloses port 25 for every user and every message, not only for the spam source. If this server delivers mail straight to other mail servers, all outgoing mail stops and waits in the queue until you run/go/smtp unblock.
Quick start
# Stop all outgoing port 25 connections (spam emergency)
/go/smtp block
# Allow them again
/go/smtp unblock
# Make Postfix also listen on port 26
/go/smtp enable
Syntax
/go/smtp block
/go/smtp unblock
/go/smtp enable
/go/smtp 26
/go/smtp [anything else]
The command writes the call and a timestamp to /var/log/go/smtp.log. Run it as root.
Arguments
Matching is case-sensitive.
| You type | What happens |
|---|---|
block |
Sends the alerts, then blocks outgoing port 25. |
unblock |
Removes the outgoing port 25 block. |
enable or 26 |
Postfix also listens on port 26. The setting is saved as 26. |
| Nothing, or any other word | Port 26 is turned off. The setting is saved as 25. |
[!WARNING] Only the exact words above are recognized. A typo such as
blokorBlockdoes not give an error. It falls through to the last row and turns port 26 off, then restarts Postfix.
Output
| Mode | Output |
|---|---|
block |
Port 25 is closed |
unblock |
Port 25 is opened |
enable, 26, or other |
Nothing |
block and unblock end with exit status 1, even when they work. In scripts, read the output, not the exit status.
Examples
# Block outgoing mail on port 25, then check the mail queue
/go/smtp block
postqueue -p | tail -1
# Allow outgoing mail again
/go/smtp unblock
# Add port 26 and open it in the firewall
/go/smtp enable
/go/allow 26
# Turn port 26 off again
/go/smtp disable
# Check whether the block rule is in place
sudo firewall-cmd --direct --get-all-rules # AlmaLinux, Rocky, CentOS, Red Hat, Fedora
sudo ufw status # Debian, Ubuntu
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Outgoing mail is stuck in the queue | Outgoing port 25 is blocked. | Run /go/smtp unblock once the spam source is fixed. |
block printed Port 25 is closed, but mail still goes out |
The OS name is not one of the supported ones, so no firewall rule was added. The message is printed anyway. | Add the firewall rule by hand. |
| Alert says "affected source(s)" but lists none | The details are not filled in when the command is run by hand. | Find the source with mailtop or outgoing. |
| Port 26 does not accept connections | The firewall doesn't allow it, or the hosting provider blocks it. | Open it with allow 26. |
| Port 26 turned off by accident | A mistyped word was treated as "turn off". | Run /go/smtp enable again. |
unblock did not reopen the port |
The rule was added another way and does not match the one removed. | List the firewall rules (see Examples) and remove it by hand. |
| You received the same alert several times | Each block run sends a new email and WhatsApp message. |
Expected. |
checkmail reports port 25 as blocked |
block is active. |
Run /go/smtp unblock. |
Details
Block
- Builds an alert text and sends it by email and WhatsApp to the administrator.
- Waits 5 seconds.
- Adds a permanent rule that drops all outgoing TCP traffic to port 25, for IPv4 and IPv6:
- AlmaLinux, Rocky, CentOS, Red Hat, Fedora: a
firewallddirect rule, then a reload - Debian, Ubuntu:
ufw deny out 25
- AlmaLinux, Rocky, CentOS, Red Hat, Fedora: a
- Runs
/go/welcome. - Prints
Port 25 is closedand ends with status1.
The alert says outgoing access is restricted "for the affected source(s)", but the firewall rule is for the whole server. The rule survives a reboot.
Unblock
- Removes the same rule (
firewallddirect rule, orufw delete deny out 25). - Runs
/go/welcome. - Prints
Port 25 is openedand ends with status1.
No alert is sent.
Port 26 on
- Deletes any existing port 26 line from
/etc/postfix/master.cf. - Adds the line
26 inet n - n - - smtpd, so Postfix runs an SMTP listener on port 26. - Saves
PostfixSMTPPort = 26in GoAdmio's configuration. - Restarts Postfix.
The normal port 25 listener is not removed, so the server listens on both ports. The command does not open port 26 in the firewall.
Port 26 off
- Clears the port 26 line in
/etc/postfix/master.cf, leaving a blank line. - Saves
PostfixSMTPPort = 25in GoAdmio's configuration. - Restarts Postfix.
flowchart TD
A["smtp [argument]"] --> B{"Argument"}
B -- "block" --> C["Send email and WhatsApp alerts"]
C --> D["Drop outgoing TCP port 25"]
D --> E["Run welcome, print Port 25 is closed, exit 1"]
B -- "unblock" --> F["Remove the drop rule"]
F --> G["Run welcome, print Port 25 is opened, exit 1"]
B -- "enable or 26" --> H["Add port 26 to Postfix, save 26"]
B -- "anything else" --> I["Remove port 26 from Postfix, save 25"]
H --> J["Restart Postfix"]
I --> J
What changes
| Item | block |
unblock |
enable / 26 |
Other |
|---|---|---|---|---|
| Outgoing port 25 firewall rule | Added | Removed | — | — |
| Alerts sent | Email and WhatsApp | — | — | — |
master.cf |
— | — | Port 26 line added | Port 26 line cleared |
Saved PostfixSMTPPort |
— | — | 26 |
25 |
| Postfix restarted | No | No | Yes | Yes |
See also
| Command | Description |
|---|---|
mailtop |
Check the most active email accounts in GoAdmio |
outgoing |
Report today's outbound mail sessions |
incoming |
List today's messages received by the server's SMTP service |
checkmail |
Test whether outbound mail port 25 works from this server |
checksmtp |
Check that the server's SMTP service accepts a login on port 587 |
allow |
Open a TCP port in the server firewall |
deny |
Close a TCP port by removing its allow rule from the server's firewall |
firewall |
Install and configure the server firewall |
postfwd |
Build the Postfwd rate-limiting rules |
spam |
Track spam email accounts in GoAdmio |
email |
Change the administrator email address GoAdmio uses for notifications |