Analyzing e-mail traffic and troubleshooting e-mail problems – POP, IMAP, and SMTP

The common mail protocols for mail client to server and server to server communications are Post Office Protocol version 3 (POP3), Simple Mail Transfer Protocol (SMTP) and Internet Message Access Protocol version 4 (IMAP4).

Another common method for accessing e-mails is web access to mail, in which you have common mail servers such as Gmail, Yahoo!, and Hotmail. Some examples include Outlook Web Access (OWA) and RPC over HTTPS for the Outlook web client from Microsoft and others.

In this recipe, we will talk about the most common client-server and server-server protocols: POP3 and SMTP. We will also look at some typical problems by using the other methods.

Getting ready

When users are complaining about mail problems, first check if there are any obvious problems such as wrong username, bad password, and authentication protocols that are not configured. If none, connect Wireshark with port mirror to the complaining client; and if there are many of them, configure port mirror to the common server or the communications line connecting to it (when there is a remote server).

How to do it...

POP3 will usually be used for client to server communications, while SMTP will usually be used for server to server communications.

POP3 communications

POP3 is usually used for mail client to mail server communications. When a client cannot access the mail server, perform the following checks:

  1. First, check if the correct username and password have been configured.
  2. Then, check if the authentication has passed correctly. In the following screenshot, you can see a session opened with a username that starts with doronn@ (all IDs were deleted) and a password that starts with u6F.
  3. To see the TCP stream shown in the following screenshot, right-click on one of the packets in the stream and choose Follow TCP Stream from the dropdown menu:
    POP3 communications
  4. Any error messages in the authentication stage will prevent the communications from being established. You can see an example of this in the following screenshot where user authentication failed. In this case, we see that when the client gets the Logon failure, it closes the TCP connection.
    POP3 communications
  5. During the mail transfer, be aware that mail clients can easily fill a narrow-band communications line. You can check this by simply configuring the IO graphs with a filter on POP.
  6. Always check for common TCP indications: retransmissions, zero-window, window-full, and others. They can indicate a busy communication line, slow server, and other problems coming from the communications lines or end nodes and servers. These problems will mostly cause slow connectivity.

SMTP communications

SMTP is commonly used for the following purposes:

  • Server to server communications, in which SMTP is the mail protocol that runs between the servers
  • In some clients, POP3 or IMAP4 are configured for incoming messages (messages from the server to the client); while SMTP is configured for outgoing messages (messages from the client to the server)

When you suspect slow server-to-server communications, follow these steps to resolve the problems.

  1. Check if the servers are located on the same site:
    • If they are located on the same site, you probably have slow servers or another application problem. In most of the cases, the LAN will not cause any problems—especially when both servers are in the same data centre.
    • If they are not located on the same site (when the servers are located in a remote site through WAN connections), check the load on the WAN connections. When sending large mails, they can easily block these lines—especially when they are narrow band (several Mbps).
  2. First, look for TCP problems; and check if you see them only on SMTP or on all other applications. For example, in the following screenshot, you can see many TCP retransmissions:
    SMTP communications
  3. Check if they are because of a slow SMTP server. Is it a mail problem? When you look at the following screenshot, you see that I've used the TCP Conversation statistics. After checking the Limit to display filter checkbox and clicking on Packets at the top of the window (to get the list from the higher amount of packets), we can see that only 793 packets are SMTP from the retransmitted packets. There are 9014 packets retransmitted between 172.16.30.247 and 172.16.30.2 on port 445 (Microsoft DS), 2319 packets are retransmitted between 172.16.30.180 and 192.5.11.198 on port 80 (HTTP), and so on.
    SMTP communications
  4. In this case, SMTP is influenced only by bad communications. It is not an SMTP problem.
  5. Check for SMTP errors. In the following screenshot, you see an error code 451, which is also called the local error in processing server error. Also, a list of errors is listed.

Tip

When something goes wrong, in most cases the server or the client will tell you about it. You just have to look at the messages and Google them. We will see many examples of this later.

You can also find a list of SMTP status codes in RFC 1893 (http://www.ietf.org/rfc/rfc1893.txt).

SMTP communications
  1. When you want to know which errors have been sent by the two sides, configure a filter as shown in the following screenshot:
    SMTP communications
  2. Here you can see various events:
    • Code 421: This indicates that the mail service is probably unavailable (1).
    • Code 452: This indicates that the server cannot respond, and tells you to try again later. This happens due to load on the server or a server problem (2).
    • Code 451: (code 250 is shown in the screenshot, see the following note) This indicates the user over quota (3).
    • Code 452: This indicates that the mailbox size limit has been exceeded (4).
    • Code 450: (code 250 is shown in the screenshot, see the following note) This indicates that the host was not found (5).

      Tip

      In SMTP (like in many other protocols), you can get several error codes in the same message. What you see in the packet list in Wireshark can be the first one, or a partial list of it. To see the full list of errors in the SMTP message, go to the packet details and open the specific packet, as in the following screenshot.

    When you see too many codes, it indicates unavailability of the server. check with the server administrator.

    SMTP communications

Some other methods and problems

Some other common methods that I mentioned earlier are web mail and RPC over HTTP:

  • In web mail, we connect to the server with HTTPS; therefore this is exactly like working with HTTPS, as described in Chapter 10, HTTP and DNS. After logging in to the server, if any problems occur, they will be HTTPS problems.
  • RPC over HTTPS will be same. Since RPC is a protocol which usually loads the network, it is considered to be sensitive to high delays and jitter. Microsoft came up with a solution to work with their Outlook client over HTTPS and not with the standard RPC. Again, since communication runs over HTTPS, problems will be HTTPS problems.

How it works...

Mail clients will mostly use POP3 for communications with the server. In some cases, they will use SMTP as well. IMAP4 is used when server manipulation is required, for example, when you need to see messages that exist on a remote server without downloading them to the client. Server to server communications are usually implemented by SMTP.

Tip

The difference between IMAP and POP is that in IMAP the mail is always stored on the server. If you delete it, it will be unavailable from any other machine. In POP, deleting a downloaded email may or may not delete that e-mail on the server.

In general, SMTP status codes are divided into three categories, which are structured in a way that helps you understand what exactly went wrong. The method and details of SMTP status codes is discussed in the following section.

POP3

POP3 is an application layer protocol used by mail clients to retrieve e-mail messages from the server. A typical POP3 session will look like the following screenshot:

POP3
  1. The client opens a TCP connection to the server.
  2. The server sends an OK message to the client (OK Messaging Multiplexor).
  3. The user sends the username and password.
  4. The protocol operations begin. NOOP (no operation) is a message sent to keep the connection open, STAT (status) is sent from the client to the server to query the message status. The server answers with the number of messages and their total size (in packet 1042, OK 0 0 means no messages and it has total size zero).
  5. When there are no mail messages on the server, the client sends a QUIT message (1048), the server confirms it (packet 1136) and the TCP connection is closed (packets 1137, 1138, and 1227).

In the case of encrypted connection, it will look nearly the same (see the following screenshot). After the connection establishment (1), there are several POP messages (2), TLS connection establishment (3), and then the encrypted application data.

POP3

SMTP and SMTP error codes (RFC3463)

The structure of SMTP status codes is as follows:

class . subject . detail

For example, when you see status code 450, it means the following:

  • Class 4 indicates that it is a temporary problem
  • Subject 5 indicates that it is a mail delivery status
  • Detail 0 indicates an undefined error (RFC 3463, Paragraph 3.6)

The following table lists the various classes:

Status code

Meaning

Reason

2.x.xxx

Success

Operation succeeded

4.x.xxx

Persistent transient failure

A temporary condition has prevented the server from sending the message. It can be due to server load or network bottleneck. Usually, sending the message again will succeed.

5.x.xxx

Permanent failure

A permanent problem prevented the server from sending the message. Usually server or compatibility errors.

The following table lists the various subjects:

Status code

What is it

What can be the reason

x.0.xxx

Other or undefined status

-

x.1.xxx

Addressing status

-

x.2.xxx

Mailbox status

-

x.3.xxx

Mail system status

-

x.4.xxx

Network and routing status

-

x.5.xxx

Mail delivery protocol status

-

x.6.xxx

Message content or media status

-

x.7.xxx

Security or policy status

-

The list of status details are too long to be listed here. A full list can be found in the standard pages at http://tools.ietf.org/html/rfc3463.

Some common status codes are listed in the following table:

Status code

What is it

What can be the reason

220

Service is ready

Service is running and ready to perform mail operations.

221

Service closing transmission channel

Usually OK. This is how the server closes the service when it is not required.

250

Requested mail action is OK

Message is delivered successfully.

251

Not a local user, mail will be forwarded

Everything is OK.

252

Cannot verify the user

The user couldn't be verified by the server. The mail will be delivered.

421

Service not available

The mail transfer service is not available and cannot serve incoming mail due to a transient event. This can be due to a server problem (service that is not running) or server limitation.

422

Mail size problem

The recipient mailbox has passed its quota or has a limitation on incoming mail.

431

Out of memory or disk full

Server disk is either full, or out of memory. Check the server.

432

Incoming mail queue has been stopped

It can be due to a server error (a service that stopped).

441

The receiving server is not responding

The server that sends the message indicates that the destination server does not respond.

442

Bad connection

There is a problem with the connection to the destination server.

444

Unable to route

The server was unable to determine the next hop for the message.

445

Mail system congestion

The mail server is temporarily congested.

447

Delivery time has expired

The message was considered too old by the rejecting system. This is usually due to queuing or transmission problems.

450

Requested action not taken

Message could not be transmitted. This is usually due to a problem with the mail service on the remote server.

451

Invalid command

This indicates an unsupported or out of sequence command. The action was aborted by the receiving server. This was mostly due to load on the sending or the receiving server.

452

Requested action was not taken

Insufficient storage on the receiving server.

500

Syntax error

The command sent by the server was not recognized as a valid SMTP or ESMTP command.

512

DNS error

The host server, which is the destination for the mail that was sent, could not be located.

530

Authentication problem

Authentication is required from the receiving server, or your server has been added to a black list by the receiving server.

542

Recipient address was rejected

A message indicating that your server address was rejected by the receiving server. This is usually due to Anti-spam, IDS/IPS systems, smart firewalls or other security system.

There's more...

E-mails are sometimes referred to as one of the "silent killers" of networks, especially in small enterprises that use asymmetric lines to the Internet. When sending text messages, they will not consume anything from the network; but when you send a large file of several megabytes or even tens of megabytes over a narrow-band uplink to the ISP, the rest of the users in your office will suffer from network slowdown for many seconds, even minutes. I've seen this problem in many small offices.

Another issue with mail clients is that in some cases (configurable), mail clients are configured to download all new data from the server when they start to work. If you have a customer that complains of a network slowdown at the time when all employees start their day in the office, it might be due to the tens or hundreds of clients who opened their mail clients simultaneously and the mail server is located over a WAN.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.21.229