How to Extract Email Addresses from an SMTP Server


If we are considering a social engineering attack against a target, we are probably going to need email addresses. By having the email addresses of people within an organization, we can tailor our social engineering attack to particular people and circumstances within that organization (e.g., a sales report to the sales department) and maybe spoof the email address of a colleague within the organization. In this way, they are more likely to click on a link or open a document that we send them.


There are multiple ways of collecting email addresses including Maltego, an email harvester, and others, but what if we could go directly into the organization’s SMTP server and ask it if an email address exits? Wouldn’t that be best and most reliable method?

Background on SMTP

As you know, SMTP stands for Simple Mail Transport Protocol and operates on port 25. Unlike POP3 and IMAP that operate over ports 110 and 143, respectively, SMTP is a server-to-server protocol. Clients use POP3 or IMAP to retrieve or send messages to the SMTP server, while the SMTP server then communicates to other SMTP servers.

The SMTP server, obviously, maintains a database of every email address in the organization that it must send and receive email for. It is this database that we want to access and query.

To find SMTP servers you can use Nmap or another scanning tool and look for servers with port 25 open. If port 25 is open, it is likely an SMTP server. In addition, you can use DNS querying to find the IP address of its SMTP server.

SMTP Commands

The SMTP protocol, like so many other protocols, has its own subset of commands. Here are a few of the most important SMTP commands.

  • HELO – This is the command that the client sends to the server to initiate a conversation. Generally, the IP address or domain name must accompany this command, such as HELO 192.168.101 or HELO client.microsoft.com.
  • EHLO – This command is the same as HELO, but communicates to the server that the client wants to use Extended SMTP. If the server does not offer ESMTP, it will still recognize this command and reply appropriately.
  • STARTTLS – Normally, SMTP servers communicate in plaintext. To improve security, the connection between SMTP servers can be encrypted by TLS (Transport Layer Security). This command starts the TLS session.
  • RCPT – Specifies the email address of the recipient.
  • DATA – Starts the transfer of the message contents.
  • RSET – Used to abort the current email transaction.
  • MAIL – Specifies the email address of the sender.
  • QUIT – Closes the connection.
  • HELP – Asks for the help screen.
  • AUTH – Used to authenticate the client to the server.
  • VRFY – Asks the server to verify is the email user’s mailbox exists.

Fire Up Kali & Open a Terminal

Now that we covered the basics of SMTP, let’s see if we can use this knowledge to hack the SMTP server to extract email addresses. Let’s fire up Kali and open a terminal.

Step 2Telnet into the SMTP Server

Our next step is to see whether we can manually connect to the SMTP server using telnet.

kali > telnet 25

As you can see, we have successfully connected to the Metasploitable server via telnet.

Step 3Manually Try Email Addresses

Now that we are connected via telnet to the SMTP server, we can use the SMTP commands listed above to query the server. Most importantly, we want to use the VRFY (verify) command. Using this command, followed by the email user name, will prompt the server to verify whether the user account exits, such as:

> VRFY sys

Leave a Reply

Your email address will not be published. Required fields are marked *