Java Mail---SMTP, POP3 protocol-dos Manual Email presentation Process

Source: Internet
Author: User
Tags base64 imap

Reprint Please specify source: http://blog.csdn.net/qq_26525215

This article is from the "university trip _ Remember the blog"

Introduction to e-mail protocol:

Mail server, according to the type of service provided, can be divided into the server that sends the mail to the server I receive the mail.
The server sending the mail uses the Send protocol, which is now commonly used by the SMTP protocol. Therefore, the server that typically sends mail is also known as an SMTP server.
The server receiving the mail uses the receive protocol, which is now commonly known as the POP3 protocol or the IMAP protocol, and is often referred to as a POP3 or IMAP server.
The servers that are currently seen are SMTP and POP3 servers. If you have registered 126 of the mailbox, its outgoing mail server is smtp.126.com:25, and the receiving mail server is pop3.126.com:110. (The port number is followed by the colon).
Of course, the outgoing mail server and the receiving mail server may also be the same host, but the port number must be different. The default outgoing mail server has a port of 25, and the receiving message has a port of 110.

Attention:

QQ邮箱 POP3 和 SMTP 服务器地址设置如下: POP3服务器(端口110)pop.qq.com SMTP服务器(端口25) smtp.qq.com SMTP服务器需要身份验证。 如果是设置POP3和SMTP的SSL加密方式,则端口如下: POP3服务器(端口995) SMTP服务器(端口465或587)。
Work diagram sent by mail:

Mail receiving/Sending agreement:

SMTP protocol-Outgoing mail protocol
All called Simple Mail Transfer Protocol, which defines the rules for communication between the mail client software and the SMTP server, and between two SMTP servers. The port is typically 25.

POP3 Agreement-Receive email agreement
All called the Post Office Protocol (postoffice Protocol), which defines the communication rules for the mail client software and the POP3 server. The port is typically 110.

If you are setting up SSL encryption for POP3 and SMTP, the port is as follows: POP3 server (Port 995) SMTP server (port 465 or 587).

IMAP protocol-Extension to POP3
All known as Internet Message Access protocal, an extension of the POP3 protocol that defines communication rules for mail client software and IMAP servers.

Turn on SMTP and POP3 services

In the Win7 system, the Telnet service is off by default, which is done in the following way:

1, Control Panel –> program –> turn Windows features on or off, select the "Telnet Server" and "Telnet Client" box, click OK.
2. Control Panel –> system security –> management tool –> Service –>telnet–> right-click on "Properties" –> Change "Disable" to "manual", apply, and select "Start"

Note that the first step must be taken before you can find Telnet in the second step of the service.

Telnet server no longer listed in Windows 10 client or server, for feature removal or deprecation, if you want to use, please go to Google to find third-party software to open.

Commands for SMTP email protocol

SMTP command and format:

Ehlo<SP><domain><CRLF>

The EHLO command is the first SMTP command that an SMTP mail sender must send after it establishes a connection with an SMTP mail receiver, and the parameter <domain> represents the host name of the SMTP mail sender. The EHLO command is used to replace the HELO command in the traditional SMTP protocol.
<SP>Represents a space that <CRLF> represents a carriage return.

Auth<SP><para><CRLF>

If the SMTP mail receiver requires an SMTP mail sender for authentication, it prompts the SMTP mail sender for the authentication method it uses, and the SMTP mail sender should then use this command to respond to the SMTP mail receiver, which <para> indicates the authentication method of the response ( Login means login), usually the authentication method previously prompted by the SMTP mail receiver.

The next 2 lines are your email address and password (after encoding).
Can be encoded with Base64encoder in Java

Mail<SP>From:<reverse-path><CRLF>

This command is used to specify the email address of the sender of the message, and the parameter <reverse-path> represents the email address of the person who sent it.

Rcpt<SP><forword-path><CRLF>

This command is used to specify the mailbox address of the recipient of the message, and <forward-path> the parameter represents the recipient's email address. If the message is to be sent to more than one recipient, use multiple RCPT <SP> to commands to specify each recipient's email address separately.

Data<CRLF>

This command is used to indicate that the SMTP mail sender is ready to start transmitting the message content, and all data sent after this command will be treated as the message content until " <CRLF> ." is encountered. <CRLF> The identifier indicates the end of the message content.
It's the end of the English period

Quit<CRLF>

This command indicates that a network connection to the SMTP mail sender will be closed after the SMTP mail receiver receives this command to end the mail delivery process.

DOS Mail

The preparation is Sina mailbox, note in the Mailbox server (mailbox website) to the SMTP and POP3 service switch open (receiver also need to open)!!!
126 Mailbox Server Address:
POP3 Server: pop3.sina.com
SMTP server: smtp.sina.com
Here we use the SMTP server: smtp.sina.com.

We use the following code to encode the user name and password

publicstaticvoidmain(String[] args) {        new BASE64Encoder();        "*****@sina.com";        "*********";        name = be.encode(name.getBytes());        pwd = be.encode(pwd.getBytes());        //英文可以不指定编码        System.out.println(name);        System.out.println(pwd);    }

DOS commands are as follows:

telnet smtp.sina.com25ehlo chxauth loginY2h4cG9zdGJveEBzaW5hLmNvbQ==Y2h4NjE5Njk5NjI5mail from:<[email protected].com>rcpt to:<chxpostbox@126.com>datafrom:<[email protected].com>to:<chxpostbox@126.com>subject:chx 邮件测试hello 你好啊,我进来了。大家好..

Request Login: Auth Login:
Enter the user name: After base64 encoding.
Enter the password, also after Base64 encoding.

If it is in DOS under the QQ mailbox sent, you can go to the junk mailbox to find! QQ classified it as a spam mailbox ....

POP3 protocol-Receive mail

Commands and their usage formats

user<SP>username<CRLF>

<SP>Represents a space and <CRLF> represents a carriage return
The user command is the first command that is typically sent after the POP3 client program connects to the POP3 mail server, and the parameter username represents the recipient's account name.

pass<SP>password<CRLF>  

The pass command is the command that the POP3 client program then sends after the user command is successfully passed, which is used to pass the account's password, and the parameter password represents the password for the account.

stat<CRLF>

The stat command is used to query statistics in a mailbox, such as the number of messages in a mailbox and the size of bytes consumed by messages.

list<SP>[msg#]<CRLF>  

The list command lists the message information in the mailbox, and the parameter msg# is an optional parameter that represents the sequence number of the message. When you do not specify a parameter, the POP3 server lists all message information in the mailbox, and when the parameter msg# is specified, the POP3 server returns only the information for that ordinal corresponding message.

retr<SP>msg#<CRLF>

The list command is used to get the contents of a message, and the parameter msg# represents the sequence number of the message.

dele<SP>msg#<CRLF>  

The DELE command is used to set the delete tag on a message, and the parameter msg# represents the sequence number of the message. When the POP3 server executes the DELE command, it simply sets the delete flag for the message and does not actually delete the message, only the POP3 server will actually delete all messages that have the delete tag set after the POP3 client program issues the QUIT command.

rset<CRLF>  

The RSet command clears the delete flag for all messages.

noop<CRLF>  

The NOOP command detects the connection between the POP3 client and the POP3 server.

quit<CRLF>  

The QUIT command indicates that to end the message receiving process, the POP3 server receives this command, removes all messages that have the delete tag set, and closes the network connection to the POP3 client program

Show Messages under DOS
telnet pop3.126110user chxpostboxpass chx619699629statlist1quit

STAT//Show overall information
List//List all letters
RETR N//Receive a message with a sequence number of n

Reprint Please specify source: http://blog.csdn.net/qq_26525215

This article is from the "university trip _ Remember the blog"

Java Mail---SMTP, POP3 protocol-dos Manual Email presentation Process

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.