E-Mails SMTP, POP3 and IMAP - Email Encryption and Authentication

Father

Professional
Messages
2,601
Reputation
4
Reaction score
633
Points
113
What is E-Mail
The e-mail that presents itself so uniformly under the roof of a mail client such as Thunderbird, Gmail or Apple Mail actually requires cooperation with at least two different servers. One is responsible for sending e-mails and for this purpose runs the SMTP protocol (Simple Mail Transfer Protocol).
Another server contains the mailbox where messages addressed to you arrive, and this service is provided either by the widely used POP3 protocol (Post Office Protocol Version 3) or the more convenient IMAP (Internet Message Access Protocol).
When you want to send an e-mail, it is sent to an SMTP server, which takes care of forwarding the message to the recipient. SMTP, defined in RFC 2821, is similar to FTP a simple text-based protocol consisting of a few commands. The responsible server waits for connections on TCP port 25.

E-Mail Authentication
Some SMTP servers of Internet providers do not control the identity of the sender until today. The problem is that such servers can easily be used for sending spam or even someone can fake a false identity. However, the SMTP specification does provide several possible authentication methods:
Some SMTP servers check the IP address of the host from which the connection was initiated - an ideal method for normal ISPs who only want to give access to their SMTP servers to their own customers.
Another possibility is to require the user to log on to the e-mail receiving server of the same provider as a prerequisite for sending e-mails. This procedure is called SMTP after POP.
Disadvantage: Some email clients cannot handle it, so you have to click on RECEIVE EMAIL each time before sending an email. The most secure method was added to SMTP afterwards: personal login to the SMTP server with username and password Another trick for you from me is if you buy SMTPs from someone, ask for a mailtest before you buy many SMTPs, use Telnet on Linux or Windows and test the login, EHLO and sending a mail first before you buy anything.

SMTPs that do not accept email as a format are "dead" and the person you wanna buy is either trying to rip you or just has a dead smtp.

Example:
Code:
RCPT To: [email protected]
454 4.7.1 : Relay access denied

Sending A E-Mail
You can communicate with an SMTP server using the Telnet program.
For example, such a session looks like this (Everything in the square brackets is uniform, e.g. date, IP):
Code:
telnet smtp.provider.com smtp
220 smtp.provider.com ESMTP [date]
HELO smtp.provider.com
250 smtp.provider.com Hello[ip]
MAIL From: [email protected]
250  is syntactically correct
RCPT To: [email protected]
250  verified
DATA
354 Enter message, ending with "." on a line by itself
FROM: [email protected]
To: [email protected]
Subject: Welcome This is a sample message for viperzcrew learning .
250 OK id=[id]
QUIT
221 smtp.provider.de closing connection

Who has seen it correctly, all numbers like 220,250 are answer from the server so do not type.
The following SMTP commands are used in this short conversation:
HELO: With this command the client logs on to the server, possibly the already described check of the client IP address takes place in this context. Some SMTP servers also require the specification of a domain name behind the command.
MAIL: This command initiates the creation of a new message, the sender must be specified in the format: From: MAILADDRESS or From: Name.
RCPT: Specifies a recipient in the format: To: EMAILADDRESS or To: Name.
DATA: All following lines of the client are considered part of the actual e-mail message until a line follows that contains only a dot (.). QUIT: The session is terminated and all e-mail messages created up to this point are sent.
The e-mail message itself (between DATA and the closing line with the dot) is a classic text message, the structure of which is described in RFC 822. In principle, it consists of several header lines in the format Field Name: Value, followed by an empty line and the actual text. The minimal header contains the sender (From), the recipient(To) and a subject.
The sender and recipient may have different formats as with the SMTP commands MAIL and RCPT. Other common header fields are the copy recipients (Cc for carbon copy) and the invisible copy recipients (Bcc for blind carbon copy). The normal copy receivers are displayed in the message, the invisible ones are not.

MIME & MIME Format
Types An alternative format for e-mails, which is already more commonly used today than RFC 822, is the MIME format. The different aspects of MIME are described in RFC 2045 to 2049. The abbreviation MIME stands for Multipurpose Internet Mail Extensions. It is a format suitable for sending any text and binary data, even different types of data within the same message.

The MIME header is an extension of the RFC-822 header. The main new fields are Content-Type, which specifies the data type, and Content-Transfer-Encoding, which defines the data format.So the first one describes the content of the message, the last one the form in which it is sent.
The content type (Content-Type), usually called MIME-Type, consists of two parts separated by a slash (/): the main type and the more precise subtype. Main types are for example text(ASCII text), image(image data), audio(audio data), video(digital video) or application(proprietary data format of a certain application program).

Here are some MIME types:
text/plain - Pure text without formatting commands
text/html - HTML code
text/xml - XML code
image/gif - Image of file type GIF
image/jpeg - Image of file type JPEG
image/png - Image of file type PNG
audio/wav - Sound file of type Microsoft WAV
audio/aiff - Sound file of type APPLE AIFF
audio/mpeg - Compressed sound file of type MP3
video/avi - Digital video of type Microsoft Video for Windows
video/mov - Apple QuickTime digital video
video/mpeg - Digital video of type MPEG
application/x-shockwaveflash - Compressed Adobe Flash movie (extension .swf)
application/x-director - Compressed Adobe Director movie (extension .dcr)
multipart/mixed - Cover for several MIME subsections
multipart/alternative - Cover for the same content in several alternative formats
multipart/form-data - Envelope for POST form data including file uploads

More About MIME Types
The last three types in the table from last time make MIME especially interesting: A MIME document of type multipart/mixed can contain any number of parts, each of which has a complete MIME header and can again have any MIME type. This technique is used in modern e-mail programs to add file attachments to the mail. In contrast, a multipart/alternative type section is used to enclose the same content in various alternative formats, such as an image in GIF and PNG format, or the body of an e-mail message in plain text and HTML format.

The same procedure is used for web forms, if they support file uploads in addition to normal selection or input fields.

E-Mail Encodings
The Content-Transfer-Encoding header gives the recipient client an indication of how to interpret the incoming data. Commonly used values are approximately the following:
7bit: No encoding: suitable for 7-bit ASCII (English text). Automatic line break after 1000 characters.
8bit: No encoding: suitable for 8-bit text (international text). Also automatic line break after 1000 characters.
binary: No encoding, no automatic line break
quoted-printable: Special encoding of special characters beyond 7-bit ASCII. Example: »larger« to »gr-FC=DFer«.
base64: Preferred encoding for binary data. A special algorithm repackages the data 7- bit compact. This format is not readable by humans, even if plain text is encoded (e.g. "Hello World" becomes "SGFsbG8gV2VsdCEK")
The coding forms quoted-printable and base64 have the advantage that the mail message remains formally compatible with RFC 822 and can therefore be sent and received via old mail servers.

POP3
E-mail reception via a POP3 server is text-based, similar to SMTP. The server communicates via the TCP port 110. The description of POP3 is in RFC 1939. For clarification here again a Telnet based command list
Code:
telnet pop.myprovider.de
pop3
USER
sender
PASS xxxxx
LIST
RETR 1
DELE 1
QUIT

The following POP3 commands are used in the list:
USER: Specify the user name for the login
PASS: Specify the password for the login
LIST: numbered list of available e-mails with the respective length in bytes
RETR: Receive e-mail with the specified number
DELE: Delete e-mail with the specified number from the server
QUIT: End session

By default, most e-mail programs perform RETR and DELE immediately after each other, so the messages usually do not remain on the server. With IMAP servers, however, things are usually different: The special advantage of the IMAP protocol is that different folders can be set up on the mail server itself to manage mails there. In this way, IMAP facilitates e-mail management for mobile users. An IMAP server works similar to a POP3 server, but uses TCP port 142.
Another popular way of using e-mail is web-based freemail services such as GMX or Hotmail. These are common POP-SMTP combinations made accessible through a website with personal login. The program that communicates with the e-mail servers runs on the web server and is made available to the customer via browser
 
Top