JavaMail development tutorial 01 opening chapter

sequence

In fact, I have been wanting to write a series of blogs about JavaMail for a month. The reason is that I browsed the relevant video tutorials on the official website of Chuanzhi Podcast. It is a pity that I have not been exposed to computer network programming so far, especially after Java EE development, the underlying network details have been encapsulated, and I have not touched many underlying details. I have always thought that as long as the programming related to network protocols is Features specific to the C/C++ family. After watching Mr. Zhang Xiaoxiang's video, I found that Java can do what C/C++ can do, and I became interested in email development all of a sudden. Of course, after watching the video, I was only ignorant and couldn't understand it thoroughly. After all, there are many details worth chewing on. So I bought Mr. Zhang Xiaoxiang's "Detailed Explanation of Java Mail Development", which made the understanding of JavaMail clear.

I would like to thank Mr. Zhang Xiaoxiang. Although the teacher has passed away, his technical books have benefited later generations. The knowledge points of this series of tutorials are extracted from Mr. Zhang Xiaoxiang's JavaMail video tutorial and the book "Detailed Explanation of Java Mail Development", as well as the official API document from JavaMail, which is the induction, sublimation and summary of the appeal series of documents. This series of blogs is suitable for beginners who have just finished learning Java SE, students who are learning computer network programming, and Java EE developers who already have work experience to provide reference materials for JavaMail.

The content of this series of blog tutorials is roughly divided into: the explanation of the related protocols of the mail protocol, the sending of JavaMail mail, the organization structure of the email, the use of JavaMail to generate the complex structure of the email, the reception and parsing of the mail, etc. And most can always send a complex email to a friend, this email should contain attachments, hyperlinks, HTML format text and embedded pictures, and the cc and bcc of the email can also receive the content of the email normally.

basic concept

E- mail server
The system abstraction of e-mail is briefly summarized as follows:
write picture description here
As can be seen from the figure, the e-mail server mainly has the following functions:

  1. Receive emails delivered by users;
  2. Forward the mail delivered by the user to the target mail server;
  3. Receive emails forwarded by other mail servers, and store emails in other managed user mailboxes;
  4. Provide reading services for users who come to read emails.

SMTP protocol
If classified according to the transmission direction of each other, then the mail protocol is roughly divided into two types: SMTP protocol and POP3/IMAP protocol. The former mainly pushes mail, and the latter mainly pulls mail from the server to the local.

The full name of SMTP is Simple Mail Transfer Protocol, which defines the communication rules between server and server, and between server and client. The common port number is 25.

POP3 protocol
The whole process is Post Office Protocol, a data-based protocol, which defines the rules for communication between the client and the server, and the commonly used port number is 110.

The full name of IMAP protocol
is Internet Message Access Protocol, Internet Message Access Protocol. It is an extension of POP3 protocol and defines the communication rules between mail client and mail server.

User Agent
User agent is commonly known as a mail client, or it can be called a mail reader. Its role is to facilitate users to read, reply, forward, save and compose mail messages. At present, the popular mail clients include FoxMail, Outlook, Thunderbird, etc. Since the blogger's operating system uses ubuntu, the experimental environment is based on Thunderbird.

DNS
DNS and Appeal Protocol are in the TCP/IP protocol suite: the application layer. DNS is a domain name resolution system. Its function is to map domain names to IP addresses, and the process of converting domain names to IP addresses is called domain name resolution. In addition, DNS also has the function of reverse domain name resolution.

The DNS resolution process is a bit complicated. I won't go into details here. Why should DNS be associated with email development? That is because the SMTP protocol communicates with both the client and the server. The server determines whether the sent mail is sent through the mail client (user agent) or an SMTP server by judging whether its computer name is The computer name registered in the DNS system.

If you see this, you already feel foggy, or you dislike the concept of introduction is too simple and rough. Don't worry, the following chapters will take you closer to the palace of JavaMail development from the actual hands-on point.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325980854&siteId=291194637