SMTP has two old commands that were helpful in the friendly early internet and are mostly a liability today. VRFY asks the server whether a given user or address exists, and EXPN asks the server to expand a mailing list into its member addresses. Both were meant to help administrators debug delivery. In the modern internet they give attackers a free, fast way to learn which accounts exist, which names are valid on your domain and who belongs to internal lists, information that feeds spam, phishing and password attacks. Nearly every hardening guide says to disable them. This guide explains what the commands do, what they reveal, how to turn them off on common servers, what to use instead for legitimate checks and how to confirm the result. It pairs with tarpitting and rate shaping, brute-force defence and reading an SMTP transcript.
What the commands do
C: VRFY alice
S: 252 2.0.0 Alice Example <[email protected]>
C: VRFY nobody
S: 550 5.1.1 <nobody>: Recipient address rejected: User unknown
C: EXPN staff
S: 250-2.1.5 Bob Smith <[email protected]>
S: 250-2.1.5 Carol Jones <[email protected]>
S: 250 2.1.5 Dave Brown <[email protected]>RFC 5321 describes both commands and explicitly allows servers to refuse them, replying with 252 (cannot verify, but will accept the message), 502 (command not implemented) or 550 (access denied). It also notes that VRFY and EXPN can be disabled for security reasons. In practice almost every public server answers 252 or 502 for both commands.
Why they matter
| Exposure | What an attacker gains |
|---|---|
| Valid account names | A list of real usernames to try in password guessing or credential stuffing |
| Full names behind addresses | Material for convincing phishing and social engineering |
| Distribution list members | A map of who works where and who receives which mail |
| Naming convention | Confirms patterns such as first.last, so more addresses can be guessed |
| Internal alias structure | Reveals shared mailboxes and system accounts that should stay private |
| Low cost | No authentication is needed and responses arrive in milliseconds |
Address probing through RCPT TO
Disabling VRFY does not remove all enumeration, because a normal delivery attempt also reveals validity: the server accepts or rejects RCPT TO for each recipient. Public servers must reject unknown recipients at SMTP time (to avoid backscatter; see the null sender), so a patient attacker can still test addresses one by one. You cannot hide this entirely, but you can raise the cost: rate-limit recipients per connection and per client, delay or disconnect after repeated unknown-user errors, alert on high rates of 550 replies and consider an anti-harvesting policy on edge gateways. Some environments with high sensitivity accept all recipients at the edge and bounce later; that approach causes backscatter and is generally not recommended.
Disabling the commands
| Server | Setting | Notes |
|---|---|---|
| Postfix | disable_vrfy_command = yes in main.cf, then postfix reload | Postfix then answers VRFY with 502 |
| Exim | Ensure the ACL acl_smtp_vrfy is not permissive; the default denies VRFY from non-trusted hosts | Check the ACL and the host list allowed to verify |
| Sendmail | Add noexpn and novrfy (or goaway) to PrivacyOptions in sendmail.mc and rebuild the configuration | The goaway option sets several privacy flags at once |
| Microsoft Exchange | VRFY and EXPN are not supported on default receive connectors | Review connector settings and anonymous permissions |
| Courier, Haraka, others | Consult the documentation; many do not implement the commands | Test the behaviour instead of assuming |
| Gateways and cloud filters | Often answer 252 or 502 by design | Verify with a test |
# Postfix
postconf -e 'disable_vrfy_command = yes'
postfix reload
# Quick test (replace host and user)
printf 'EHLO test.example\r\nVRFY postmaster\r\nEXPN staff\r\nQUIT\r\n' | nc mail.example.com 25An acceptable test result is a reply such as 502 (not implemented), 252 without disclosing details, or 550/554 that is the same for every name. A reply that returns a mailbox name for one input and an error for another still allows enumeration.
Legitimate needs and alternatives
- Debugging delivery. Use
RCPT TOin a controlled test from a trusted host, the server log and the queue. See reading mail logs. - Checking whether an address exists before sending. Use a verification service that combines syntax, DNS and risk checks, or simply send and process bounces. Direct mailbox probing is unreliable (catch-all servers) and may be treated as abuse. See the email validator.
- Listing members of a list. Use the list management tool with proper authentication rather than a public SMTP command.
- Internal tools. If an internal application needs address lookup, give it an authenticated directory query (LDAP or an API) instead of SMTP.
Related hardening items
- Disable or restrict other legacy features you do not use: ETRN, TURN, DEBUG and WIZ in very old software.
- Hide detailed software versions in the banner where the policy allows. This is minor, but avoids needless disclosure.
- Require TLS and authentication on submission ports and keep port 25 for server-to-server mail. See ports.
- Ensure the server is not an open relay. See open relay checks.
- Rate-limit connections, recipients and unknown-user errors. See tarpitting.
- Use consistent replies for unknown users and disabled accounts so responses do not reveal which is which.
- Monitor for scans: many short connections from one IP issuing VRFY, EXPN or sequences of RCPT TO with sequential names.
Responses that avoid leaking
If you cannot disable the commands outright, for example on a gateway that you do not control, aim for uniform behaviour. A server should answer VRFY for existing and non-existing names in the same way, ideally with 252, which tells the client it cannot verify the user but will attempt delivery, or 502. It should not return different text, different timing or a full name for valid users. Timing is easy to overlook: a lookup that takes 5 milliseconds for unknown names and 50 for valid ones is itself an oracle. The same goes for RCPT TO: if an unknown mailbox is rejected instantly but a disabled mailbox causes a slow database lookup, attackers can measure the difference. Aim for consistent replies, consistent timing and a hard limit on how many failures one client may collect.
Also consider the information in your bounce messages and auto-replies. An out-of-office reply from a real mailbox confirms that it exists, and a bounce that includes detailed directory data can reveal internal structure. For public addresses these trade-offs are acceptable, but for sensitive internal accounts consider routing external mail through a gateway that answers uniformly. Whatever your policy, write it down so administrators and auditors know which behaviour is intended.
How to test your server
- Connect from outside your network with a tool such as Swaks, netcat or
openssl s_client -starttls smtp. - Send EHLO, then
VRFYwith a name you know exists and one you know does not, and compare replies. - Send
EXPNwith the name of a list or alias. - Try RCPT TO for existing and non-existing recipients and count how many unknown-user errors the server tolerates before slowing or disconnecting.
- Repeat after each configuration change or upgrade, and add the test to your regular security checks.
- Record results and share them with the owner of the gateway if the answer comes from a front-end appliance.
VRFY and EXPN belong to a gentler era. Turning them off costs nothing, removes an easy source of leaked information and sets the right tone: your server answers what it must for delivery and nothing more. Pair it with rate limits on recipient probing and you have closed the cheapest enumeration routes.
Check how your server looks from outside Test your sending IP for listings and exposure.
References and further reading
Frequently asked questions
What does the SMTP VRFY command do?
It asks the server whether a user or address is valid and may return the full mailbox name.
Why should VRFY and EXPN be disabled?
They let anyone enumerate accounts and list members without authentication, which helps spam, phishing and password attacks.
How do I disable VRFY in Postfix?
Set disable_vrfy_command = yes in main.cf and reload Postfix.
Does disabling VRFY stop address harvesting?
No. RCPT TO responses still reveal valid addresses, so add rate limits and alerts for repeated unknown-user errors.
How can I test whether my server answers VRFY?
Connect with netcat or Swaks, send EHLO then VRFY for a known and unknown name and compare the replies.