What is the difference between pop3 and smtp. What is an email protocol

The functioning of e-mail is carried out using three protocols: SMTP, POP3 and IMAP. Without them, e-mail cannot work. One of the features of these protocols is their narrow focus: it is fundamentally impossible to use them for other purposes, which, moreover, does not make sense.

The second feature of mail protocols is their single-tasking. For example, a protocol that sends messages is not capable of receiving them, and vice versa. That is why such protocols work in pairs (SMTP+POP3 or SMTP+IMAP).

      1. smtp protocol

SMTP (Simple Mail Transfer Protocol, simple mail transfer protocol) is a protocol used to send mail from users to servers and between servers for further forwarding to the recipient. Before doing this, the protocol establishes a connection between computers, which guarantees the delivery of the message. The SMTP protocol is very simple and effective, but this efficiency does not extend to all tasks and possibilities. So, it does not have even the simplest authentication mechanism and the ability to encrypt data during transmission between mail servers. The biggest disadvantage of SMTP is its inability to send graphics.

In order not to abandon this rather good protocol, it was decided to extend it with several useful and necessary extensions. Such an extension, for example, is MIME (Multipurpose Internet Mail Extensions, a multipurpose Internet mail service extension), thanks to which it is possible to send files of any format and content. In addition, the UUENCODE standard has been developed, which allows text messages to be transmitted in different encodings.

      1. pop3 protocol

POP3 (Post Office Protocol 3, Post Office Protocol version 3) is a mail protocol used by an email client to receive email messages from a server.

POP3 usually works in tandem with the SMTP protocol, which allows you to organize an efficient system for sending and receiving electronic messages.

The protocol interface is even simpler than the SMTP interface, and there are certain inconveniences associated with this. So, there is no possibility to selectively download a letter or view the contents of a letter directly on the mail server.

      1. imap protocol

IMAP (Interactive Mail Access Protocol, interactive email access protocol) is the most "advanced" mail protocol designed to receive electronic messages from a mail server.

Similar to POP3, it is used to work with incoming letters, however, it provides additional functions, in particular, the ability to search by keyword without saving mail in local memory.

IMAP provides the user with extensive options for working with mailboxes located on a central server. A mail program that uses this protocol accesses the mail storage on the server as if the mail was located on the recipient's computer.

The advantages of the protocol include the possibility of partial downloading of the letter, splitting the received letter into parts with subsequent gluing, and much more. In most cases, IMAP is more convenient and efficient than POP3.

Like any network service, e-mail is implemented using a pair of programs and a protocol for the interaction between them. On the Internet side, a server program works, and on the consumer side, a client program. A characteristic feature of e-mail that distinguishes it from other Internet services is that it is based on two application protocols. One is used to send outgoing messages and the other is used to receive incoming mail. Accordingly, on the Internet side, the operation of e-mail is provided by two servers: an outgoing message server and an incoming message server. The inbox server is very often referred to simply as a "mailbox". The need for two different protocols is related to security requirements. For example, when sending messages, a strict procedure for identifying the sender is usually not needed. We encounter a similar phenomenon in regular mail, when to send a letter it is enough to throw an envelope into any mailbox. The outgoing message service is based on the SMTP protocol (Simple Mail Transfer Protocol - the simplest mail transfer protocol) and is provided on the Internet side by SMTP servers.

With incoming messages, the situation is different. To receive a message, the client must show certain rights. In regular mail, the client either presents the document at the post office (when receiving registered mail), or must have a key to his own mailbox (the key is a mechanical means of identifying a person). In fact, the incoming e-mail service acts as a post office. She checks the rights of the client based on his login name and password, after which he delivers to him the correspondence that has accumulated in the "mailbox". The most common protocol for this service is POP3 (Post Office Protocol 3 - Post Office Protocol, version 3).

POP3 protocol

It is unprofitable for small organizations to own a message transport system. This is due to the fact that in small, non-computer-based organizations, as a rule, network client workstations do not have enough resources (performance or disk space) to run a full SMTP server. In addition, it may simply be unprofitable for such e-mail users to keep a personal computer permanently connected to the Internet.

To solve this problem, a post office protocol, POP (Post Office Protocol), was developed. Its most common variant is POP3 (Post Office Protocol Version 3). This protocol allows workstations to dynamically access their mailboxes located on a server dedicated to serving e-mail in a given organization.

POP3 is the simplest protocol for a user to work with the contents of his mailbox. It only allows you to pick up mail from the server's mailbox to the client's workstation and delete it from the mailbox on the server. All further processing of the mail message takes place on the client's computer.

POP3 - the server is not responsible for sending mail, it only works as a universal mailbox for a group of users. When a user needs to send a message, he must establish a connection with some SMTP server and send his message there via SMTP. This SMTP server may be the same host where the POP3 server is running, or it may be located in a completely different place.

As a rule, when working with e-mail, small organizations use a POP3 server installed on a computer in the office to receive their correspondence, and send mail via SMTP to one of the well-available well-known SMTP servers in the city (it is not difficult to find such).

Chances are, most of you reading this guide are already familiar with the most commonly used communication technology, email. But have you ever wondered how it actually works? In this article, we will learn how this service works and what is POP3, SMTP and IMAP.

POP3(Post Office protocol version 3) is often used to communicate with a remote email server and download messages to a local email client and then delete it on the server, e.g. Thunderbird, Windows Mail, etc. However, usually email clients offer a choice - whether or not to leave copies of messages on the server. If you use multiple devices to send messages, then it is recommended to leave this feature enabled, otherwise, on another device you will not have access to sent messages that have not been saved on a remote server. It's also worth noting that POP3 is a one-way protocol, which means that data is taken from a remote server and sent to a local client.

The default POP3 ports are:

Port 110 - non-encrypted port

Port 995 is the SSL/TLS port, also known as POP3S

Step 2 - Differences between POP3 and IMAP, and what ports does IMAP have?

IMAP (application layer protocol for accessing e-mail), as well as POP3, is used to receive e-mail messages on a local client, however, it has a significant difference - only the headers of e-mail messages are downloaded, the body of the letter itself remains on the server. This communication protocol works in two directions, if changes occur on the local client, they are transmitted to the server. Recently, IMAP has become more popular as email giants like Gmail recommend using it instead of POP3.

The default IMAP ports are:

  • Port 143 - non-encrypted port
  • Port 993 is the SSL/TLS port, also known as IMAPS

Step 3 - SMTP, the protocol for outgoing email communication

Simple Mail Transfer Protocol ( SMTP) is used to communicate with a remote server and then send messages from the local client to the remote server, and ultimately to the recipient's server. On your email server, this process is controlled by a special service ( MTA). It is worth mentioning that SMTP is used exclusively for sending messages.

SMTP Ports:

  • Port 25 - non-encrypted port
  • Port 465 is the SSL/TLS port, also known as SMTPS

Conclusion

We hope that you now have a clear understanding of how mail protocols work and what ports they use. In this guide, we learned what POP3, SMTP and IMAP are and what they are used for. For example, POP3 and IMAP are used for the same purposes, but they approach these tasks in different ways. IMAP leaves the contents of the email on the server, while POP3 downloads it to your computer. Also, we learned what standard ports SMTP, POP3 and IMAP have.

The salient point of many application layer protocols is that they are simple. TCP-based protocols mostly use commands and responses in text format, making them easier for users to understand and programmers to implement.

To further illustrate, we'll look at two protocols that can be used every day to send and receive email: SMTP and POP3.
Simple Mail Transfer Protocol: SMTP
Simple Mail Transfer Protocol (SMTP) is one of the most respected internet protocols. Developed in the early 1980s, its functions are clean and simple to transfer via email and between networks and other transport systems. Thus, its use need not be limited to systems using the protocol TCP/IP. Any communication system is capable of handling lines of up to 1000 7-bit ASCII characters which can be used to execute messages over the SMTP protocol. In a TCP/IP network, however, TCP provides the transport mechanism.
V SMTP sender is a client, and the client can communicate with different servers. Messages can be sent directly from the sending host to the destination host, requiring a separate TCP connection and each copy of each message must be made. However, multiple mail recipients can run their own server SMTP.
This is most typical for the appointment SMTP messages, a server that serves a group of users, such as Internet domains. The server receives all mail destined for users and then allows them to collect using POP3 (Post Office Protocol Version 3) or other mail protocols. In addition, most SMTP clients send messages to a single "smart host" server, whose job it is to relay those messages to their possible recipients.
Transactions SMTP begin when the sender-client opens a TCP connection to the receiver using the well-known port number 25. The server acknowledges the connection by sending back a message like " 220 SMTP Server Ready«. SMTP uses a similar FTP response format that we covered earlier. Received a three-digit code, the client software should respond if everything is OK. This flock is to help people who could troubleshoot with transaction log analysis. The Application Protocol Response Codes window contains more detailed information about response message codes.
Server SMTP can refuse communication by sending back a message with the response code "421 Service unavailable". For instance, SMTP The ISP's server, provided for its subscribers to transmit outgoing mail, may fail to communicate with a host whose IP address indicates that it is not an ISP subscriber. Basic SMTP protocol has no form of access control - in the way that it can be used to send messages and this makes it impractical - so the only way in which ISPs can prevent non-subscribers such as spammers from using their mail servers to send messages.
Having received confirmation of the correct characters of the sender to the server, the server sends the string "HELO name". HELO character on the command and name, is the hostname. As we will see, the hostname is used in the edit: header, the server adds the message as it sends it along its path. This information allows the recipient to trace the path through the message.
Sending server
When the sender receives a "250 OK" acknowledgment, he can start sending messages. The protocol is extremely simple. All senders have to do is say which of the messages should supply the message content.
The message is set using the command "MAIL FROM:

". This command also tells the recipient that he is about to receive new messages, so he knows to clear his list of recipients. The address in angle brackets is the return path for the message. The return path is an address such that any error message will be generated if the message is not delivered or sent.
It is valid on the way back and is invalid, as in "MAIL FROM:<>". This is typically used when submitting a bug report. A null return path means no error reporting is required. Its main purpose is to avoid getting into a situation where messages cannot be delivered to a round-trip transfer because both sender and recipient addresses are unavailable.
Message recipients are defined using the "RCPT TO:
". Each address is enclosed in angle brackets. A message can have many recipients, and a RCPT TO: command is sent for each of them. These RCPT TO: commands are not all in the message header that arrive at their destination. In the case of Bcc messages or a list of recipient server addresses will not be displayed in the header at all.
Each recipient is acknowledged with a "250 OK" response. The recipient can also be rejected when using a response with a 550 response code. It depends on how the server has been configured. Remote access to provider's servers SMTP can accept every RCPT TO: command, even if the specified address is invalid, since the server does not know that the address is invalid until it does a DNS lookup on it. However, a mail server designed to accept messages for local users or a specific domain will reject mail for addresses that are not in that realm.
Other responses may be received in response to RCPT TO: messages that the server SMTP was helpful. If the address is incorrect, but the server does not know the correct address, it may reply “251 User not local; send
' or '551 User is not local, please try
". Note the different response codes indicating whether the server is forwarding the message or not. These responses are not generic, and the mail client may simply send a 551 response as an error rather than trying to parse alternative addresses from the response body.
For the sake of completeness, it should be noted that RCPT TO: commands can specify routes, not just addresses. The route will be expressed as "RCPT TO: ».
Text messages.
Once all recipients have been specified, all the sender has to do is send the message. It first sends a "DATA" command and then waits for a response like: "354 Start mail input, from the end .". The message will be sent as a sequence of lines of text. But no acknowledgment will be received for each line, although the sender should monitor the response, which indicates errors.
At the end of the message, as indicated in the answer above, a period (dot) on the line of its own. Thus, one of the simplest, but most important things that an email client must do is make sure that a line containing a single period does not appear in the text itself. At the end of the message is acknowledged with the response "250 OK". It is worth noting that SMTP not in the least interested in the content of the message. This can be anything, although strictly speaking messages must not contain any characters with ASCII values ​​between 128 and 255, and lines of text must not exceed 1000 characters. It is also not required that the sender and recipient address headers used by SMTP commands, making them easy for messages to appear to come from someone other than the true sender.

SMTP protocol

SMTP(English) Simple Mail Transfer Protocol Simple Mail Transfer Protocol is a network protocol designed for the transmission of e-mail over TCP/IP networks.

SMTP is used to send mail from users to servers and between servers for further forwarding to the recipient. To receive mail, the mail client must use the POP3 or IMAP protocols.

Data is transferred using TCP, which typically uses port 25 or 587. Messages between servers typically use port 25.

To deliver a message to the addressee, it is necessary to forward it to the mail server of the domain in which the addressee is located. This is usually done using an MX record. Mail eXchange-- mail exchange) DNS systems. If there is no MX record, then an A record can be used for the same purpose. Some modern implementations of SMTP servers (for example, Exim) can also use an SRV record (RFC 2782) to determine the server serving mail in the recipient's domain.

SMTP Server is a state machine with an internal state. The client sends a command string to the server<пробел>parameters<перевод строки>. The server responds to each command with a string containing a response code and a text message separated by a space. The response code is a number from 100 to 999, represented as a string, interpreted as follows:

  • 2XX - command completed successfully
  • 3XX -- waiting for additional data from the client
  • 4XX - temporary error, the client should try again after a while
  • 5XX -- fatal error

The text part of the answer is for reference only and is intended for a person, not a program.

SMTP security and spam

Initially, SMTP did not support a single authorization scheme. As a result, spam became an almost unresolvable problem, since it was impossible to determine who the real sender of the message was - in fact, you can send a letter on behalf of any person. At present, attempts are being made to solve this problem using the SPF, Sender ID, Yahoo Domain Keys specifications. There is currently no single specification.

POP3 protocol

POP3(English) Post office Protocol Version 3-- Post Office Protocol Version 3) is a network protocol used to receive e-mail messages from a server. Usually used in conjunction with the SMTP protocol.

Rice. 10. Scheme "Client-server via POP3 protocol"

Description of the POP3 protocol

Consider the one shown in Fig. 10. scheme "Client-server via POP3 protocol". The design of the POP3 protocol allows the user to contact his mail server and retrieve the mail that has accumulated for him. The user can access the POP server from any Internet access point. At the same time, he must launch a special mail agent (UA) that works according to the POP3 protocol and configure it to work with his mail server. So, at the head of the POP model is a separate personal computer operating exclusively as a mail system client (server). We also emphasize that messages are delivered to the client using the POP protocol, but are still sent using SMTP. That is, there are two separate interface agents to the mail system on the user's computer - delivery (POP) and sending (SMTP). The designers of the POP3 protocol call this situation "split UAs". The concept of separate agents is briefly discussed in the POP3 specification.

The POP3 protocol specifies three stages in the process of receiving mail: authorization, transaction, and update. Once the POP3 server and client have established a connection, the authorization phase begins. During the authorization stage, the client identifies itself to the server. If the authorization is successful, the server opens the client's mailbox and the transaction phase begins. In it, the client either asks the server for information (for example, a list of mail messages) or asks it to perform a certain action (for example, issue a mail message). Finally, at the update stage, the communication session ends. The following are the POP3 protocol commands that are required for an Internet-based implementation of the minimum configuration.

POP protocol version 3 commands (for minimal configuration)

USER Identifies the user with the given name.

PASS Specifies the password for the client-server pair.

QUIT Closes a TCP connection

STAT Server returns number of messages in mailbox plus mailbox size

LIST Server returns message IDs along with message sizes (command parameter can be a message ID)

RETR Retrieves a message from the mailbox (requires a message ID argument)

DELE Marks a message for deletion (requires a message ID argument)

NOOP The server returns a positive response but does nothing

LAST The server returns the largest message number from those previously accessed

RSET Cancels the deletion of a message previously marked with a DELE command.

Several commands are defined in the POP3 protocol, but only two responses are given to them: +OK (positive, similar to an ACK confirmation message) and -ERR (negative, similar to a NAK not acknowledged message). Both responses confirm that the server has been contacted and is responding to commands at all. As a rule, each answer is followed by its informative verbal description. RFC 1225 has examples of several typical POP3 sessions. Now we will consider several of them, which will make it possible to catch the sequence of commands in the exchange between the server and the client.

After the program has established a TCP connection to the POP3 protocol port (official number 110), you must send the USER command with the username as a parameter. If the server response is +OK, send a PASS command with that user's password:

CLIENT: USER kcope ERVER: +OK CLIENT: PASS secret SERVER: +OK kcope's maildrop has 2 messages (320 octets) (Kcope's mailbox has 2 messages (320 bytes) ...)

POP3 transactions

The STAT command returns the number of messages and the number of bytes in the messages:

SERVER: +OK 2 320

The LIST command (with no parameter) returns a list of messages in the mailbox and their sizes:

The NOOP command does not return any useful information, except for a positive response from the server. However, a positive response means that the server is connected to the client and is waiting for requests:

The following examples show how the POP3 server performs actions. For example, the RETR command retrieves the message with the specified number and puts it in the local UA's buffer:

CLIENT: RETR 1 SERVER: +OK 120 octets SERVER: (POP3 server sends whole message) SERVER: . . . . . .

The DELE command marks the message to be deleted:

SERVER: +OK message 1 deleted ... CLIENT: DELE 2 SERVER: -ERR message 2 already deleted message 2 already deleted)

The RSET command removes the deletion marks from all previously marked messages:

(2 messages in mailbox (320 bytes))

As expected, the QUIT command closes the connection to the server:

CLIENT: QUIT SERVER: +OK dewey POP3 server signing off CLIENT: QUIT SERVER: +OK dewey POP3 server signing off (maildrop empty) CLIENT: QUIT SERVER: +OK dewey POP3 server signing off (2 messages left)

Note that messages marked for deletion are not actually deleted until the QUIT command is issued and the refresh phase begins. At any time during the session, the client has the option to issue a RSET command and all messages marked for deletion will be restored.

IMAP protocol

IMAP(English) Internet message Access Protocol) is an application layer Internet protocol for accessing e-mail.

IMAP provides the user with rich options for working with mailboxes located on a central server. A mail program that uses this protocol accesses the mail storage on the server as if the mail was located on the recipient's computer. E-mails can be manipulated from the user's (client's) computer without the need to constantly send files with the complete contents of the messages back and forth from the server.

Advantages over POP

IMAP was designed to replace the simpler POP3 protocol and has the following advantages over the latter:

  • · Letters are stored on the server, not on the client. It is possible to access the same mailbox from different clients. Also supported simultaneous multiple client access. There are mechanisms in the protocol by which a client can be informed of changes made by other clients.
  • · Support for multiple mailboxes (or folders). The client can create, delete and rename mailboxes on the server, as well as move messages from one mailbox to another.
  • · It is possible to create shared folders that can be accessed by multiple users.
  • · Information about the state of letters is stored on the server and is available to all clients. Emails can be marked as read, important, etc.
  • · Support search on the server. There is no need to download many messages from the server in order to find the one you need.
  • · Support online operation. The client can maintain a permanent connection with the server, while the server informs the client in real time about changes in mailboxes, including new messages.
  • · A mechanism for extending protocol capabilities is provided.