Java email development-Introduction to the basic concepts of email

Source: Internet
Author: User
Tags imap

Email is used to send and communicate confidence on the Internet. It is one of the most important Internet services. According to statistics, 30% of Internet businesses are email-related. At the same time, we cannot deny that it plays a very important role in our daily life, work and office. For example, many office automation projects (OA) require the function of sending emails. manual methods such as OutLook are not suitable. In this high-speed era, we need to provide work efficiency, automate your work. At the same time, the mail sending function is also required for many websites: send a welcome email containing the registration information to newly registered users, send the latest website activity information to all registered members through E-Mail, and so on.

 

Before starting email development, we need to understand several concepts: email system, email server, email, mail client software, Mail Transfer Protocol, and email transmission process.

 

Email System

Similar to traditional postal services, an email system consists of an email Post Office, an email sending and receiving system. The sender and receiver send and receive emails through the email sending and receiving system. They are actually the mail client program running on the computer. The email post office serves as a bridge. It is actually a mail server program running on the server. The email processing process is similar to that of the postal service.

 

Email server

An email server is a device used to manage email sending and receiving. A large number of email servers are provided on the Internet, such as 126, 163, and hotmail ....

Email server provides the following functions:

1. Receive user-delivered mails.

2. Forward the emails delivered by the user to the target email server.

3. receive emails forwarded by other email servers and store the emails in the user mail managed by the email server.

4. Provides the mail reading service for the users who come to read the mail.

The email server forms the core of the email system. Each recipient has a mailbox on a mail server ). Bob's mailbox is used to manage and maintain the mail messages that have been sent to Bob. A typical journey of mail message is from the user proxy of the sender, the mail server of the sender, to the mail server of the recipient, and then to the mailbox of the recipient. When Bob wants to view the mail messages in his mailbox, the mail server that stores the email will authenticate him with the username and password provided by Bob. Alice's email server has to handle Bob's email server failure. If Alice's mail server cannot immediately deliver the mail messages to Bob's mail server, Alice's server stores them in the message queue and will try again later. This kind of attempt is usually executed every 30 minutes or so: if the attempt fails after several days, the server removes the message from the message queue, notify the sender (Alice) with another email ).

 

Email

Email is a modern communication method that transfers and receives information from each other through the network. It is a communication method that provides information exchange by electronic means. It is the most widely used service on the Internet. Through the online email system, users can enjoy very low prices, in a very fast way, you can contact network users in any corner of the world. These emails can be text, images, sounds, and other methods. At the same time, users can get a large number of free news and special emails, and easily search for information.

An email consists of an envelope and content. An envelope is also called a mail header. The email server delivers the mail based on the confidence in the envelope. The content is called the mail body, which is used to provide the specific content of the mail.

The email address on the Internet is globally unique in the format of "mailbox name @ email server domain name ". The domain (email domain) is the basic management unit of the email server. The mail service is based on the domain, and each mailbox corresponds to one user. The email server domain name must be a registered DNS domain name and must match the MX (Mail switch) record. DNS is used to resolve domain names and host names to IP addresses. MX records point to the mail server host record of this domain name, which is dedicated to mail service.

 

Email client software

The mail client is responsible for communicating with the mail server. It is mainly used to help users send emails to the SMTP server and POP3/IMAP mail server to read users' emails. The mail client software is generally integrated into writing, sending, and receiving emails.

 

 

Email

Each email server can start multiple email addresses, which are also called e-mail addresses. It is similar to a mailing address in real life. Users can use it to receive emails from others and send emails to others.

To obtain an email address, you must apply on the email server. Specifically, an email address is actually an account applied for on the email server. The email server keeps the received emails to the mailbox space allocated to an account, you can log on to the email server using the user name and password you have applied for to view the emails you have received from this address.

 

Email transmission process

The email system adopts the customer/Server mode. Email transmission requires the following three important modules:

MUA (Mail User Agent): a User uses it to deal with the email server. MUA is actually the mail client software.

MTA (Mail Transfer Agent): it is mainly responsible for processing all received and sent mails, providing Mail sending services for MUA or MTA, and receiving mails sent by other MTA.

MDA (Mail Delivery Agent, Mail Delivery Agent): it is responsible for local Delivery of Mail. When the MTA decides to send a mail to a local user, the MTA delivers the mail to the MDA program for distribution, that is, the mail is delivered to the user.

The specific transfer process is as follows:

1. The sender uses MUA to send the email to the MTA.

2. After receiving the email, the MTA determines whether the recipient is a local account. If the email is a local account, the MTA sends the email to the Account's email address. After completing the sending process, it jumps to step 1. If not, perform the next step.

3. the MTA determines how to forward mail based on its email relay forwarding settings.

4. the MTA for the final purpose will be handed over to its MDA for processing, and the MDA will deliver the mail to the recipient's mailbox.

5. The recipient uses the POP/IMAP protocol to connect to the server where the mailbox is located, and requests to check whether there are emails in his inbox. If there are emails, the recipient's MUA will be transmitted through it.

Note: The POP or IMAP server software prompts the mail access service, instead of the MTA that received the mail, the roles of the two are separated.

 

Email transmission protocol

The email service transmission mainly uses the following three network protocols:

SMTP (Simple Mail Transfer Protocol)

SMTP is Simple Mail Transfer Protocol. The standard TCP port is 25. MUA sends the email to MTA, and MTA sends the email to the next MTA. SMTP is required. SMTP is designed to deliver messages reliably and efficiently. It is independent of the transfer subsystem and requires only one channel that ensures the order of transmitted data units.

SMTP is a "one-way" protocol that prevents users from receiving emails from other email servers. It uses the Client/Server mode. The SMTP process responsible for sending emails is the SMTP client, and the SMTP process responsible for receiving emails is the SMTP server. A complete SMTP communication process consists of establishing a connection, sending an email, and releasing a connection.

Establish a connection: first, emails to be sent by the sender are sent to the mail cache. The SMTP client periodically scans the mail cache. Once an email is found, a TCP connection is established with the SMTP server, then, send the HRLLO command to attach the sender's host name.

Send MAIL: the SMTP client uses the MAIL command to start sending the MAIL. This command provides the sender address, then runs the RCPT command, and provides the recipient address. Finally, it executes the DATA command to send the MAIL content.

Release connection: After the mail is sent, the SMTP client sends an OUT command request to close the TCP connection.

POP (Post Office Protocol)

POP is Post Office Protocol. Standard TCP port 110. It is mainly used for receiving emails. MUA connects to the user inbox of the MTA through the POP protocol to read or download emails from the user's inbox.

Currently, many POP protocols are used: POP3. POP3 uses TCP as the transmission protocol.

IMAP (Internet Information Access Protocol)

IMAP is an Internet Message Access Protocol. The standard TCP port is 143, which also enables MUA to receive emails from the MTA. The IMAP Protocol version of the target ball is IMAP4.

Both POP and IMAP can be used to receive emails, both of which adopt the customer/Server mode. The main difference between POP and IMAP is that they retrieve emails in different ways. When POP is used, emails reside on the server. Once an email is received, all emails are downloaded from the server to the user's computer. However, IMAP can understand how emails are stored on the server, and the downloaded emails are still stuck on the server for archiving and sharing.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.