SMTP
SMTP is how mail moves across the internet — and a chatty or misconfigured mail server will confirm valid usernames for you and, at its worst, relay spoofed mail for anyone who asks. VRFY enumeration and open-relay testing are the two things you check every time.
Protocol: TCP · Port: 25 (and 587 for submission, 465 for SMTPS)
What Is SMTP?
The Simple Mail Transfer Protocol (SMTP) sends email across an IP network. It’s usually paired with IMAP or POP3, which handle fetching mail, while SMTP handles sending. Once an email is transmitted the connection closes, and the server forwards it on toward its destination. By default SMTP is unencrypted — commands, data, and authentication all travel in plain text — so it’s typically wrapped in SSL/TLS. To fight spam, modern servers use ESMTP with SMTP-Auth, so only authorized users can send. When people say “SMTP” today, they usually mean ESMTP.How Mail Flows
The journey of a message touches several agents:- The client (MUA — Mail User Agent) splits the email into a header and body and hands it to the SMTP server.
- The server’s MTA (Mail Transfer Agent) checks the mail for size and spam, then stores it.
- An optional MSA (Mail Submission Agent), also called a relay server, validates the email’s origin to relieve the MTA.
- The MTA looks up the recipient mail server’s IP in DNS.
- At the destination, the packets are reassembled and the MDA (Mail Delivery Agent) drops the message in the recipient’s mailbox.
Default Configuration
A common Linux MTA is Postfix, configured in/etc/postfix/main.cf. SMTP is driven by a small set of commands that tell the server what to do:
| Command | Purpose |
|---|---|
HELO / EHLO | Open the session and identify the client (EHLO is the ESMTP version) |
MAIL FROM: | Specify the sender |
RCPT TO: | Specify the recipient |
DATA | Begin the message body (ends with a lone .) |
VRFY | Verify whether a user exists |
EXPN | Expand a mailing list to its members |
RSET | Reset the session |
QUIT | Close the connection |
Dangerous Settings
To get past spam filters, a sender can route mail through a relay server that recipients trust — a known, verified SMTP server. Normally the sender must authenticate to the relay first. The problem: administrators often don’t know which IP ranges they need to permit, so to avoid breaking mail flow they permit all of them. That’s the open-relay misconfiguration you’ll find on both external and internal tests.Open Relay Configuration
Footprinting the Service
Nmap — Commands and Open-Relay Test
The defaultsmtp-commands script uses EHLO to list everything the server supports:
smtp-open-relay script runs 16 different tests to determine whether the server is an open relay. Add -v to see which tests run:
Telnet — Interact Directly
Usetelnet to open a raw TCP session and drive the server by hand. Start with HELO/EHLO:
Enumerate Users with VRFY
VRFY asks the server whether a user exists. It doesn’t always work, but when it does it’s a free username oracle:
Depending on configuration, some servers return code 252 for every
address — confirming users that don’t actually exist. Treat 252-for-everything
as “VRFY enumeration is unreliable here.” A full list of SMTP response codes
is at serversmtp.com.
smtp-user-enum — Brute-Force Usernames
WhenVRFY is enabled, smtp-user-enum will run a wordlist through it:
-M mode can also be EXPN or RCPT if VRFY is disabled — those verbs sometimes leak users when VRFY doesn’t.
Metasploit — Enumerate Users
The Metasploit auxiliary module does the same job and sometimes gets better results:Quick Reference
| Command | Purpose |
|---|---|
nmap -p25 --script smtp-commands <ip> | List supported SMTP commands |
nmap -p25 --script smtp-open-relay -v <ip> | Test for open relay (16 checks) |
telnet <ip> 25 → EHLO | Manual interaction |
VRFY <user> | Check if a user exists |
smtp-user-enum -M VRFY -U <wordlist> -t <ip> | Brute-force usernames |
auxiliary/scanner/smtp/smtp_enum | Metasploit user enumeration |
Next: IMAP / POP3 — reading mailboxes and hunting credentials in mail stores.