Java mail (1): Telnet enables sending and receiving emails

Source: Internet
Author: User

Recently, I want to make a mail-parsing task. By the way, I would like to introduce the Java mail API. I 've done it before, and now I forget to write it into 108,000. If I want to talk about it, I have to learn how to use it, or you can throw it all.

Speaking of mailbox, tools are commonly used at work, and they are not used at school. There are quite a few mailbox systems in China, such as 163, Sina, Sohu, and QQ. These are well-known for common users' mailboxes, and many for enterprise users. There are two kinds of mailbox protocols: one is the SMTP protocol for sending mail, and the other is the POP3 and IMAP protocols for receiving mail. Each mailbox system is implemented according to these two protocols.

We may usually use the mailbox client, which will be provided by all major mailbox systems in C/S, such as outlook, Foxmail, and B/S, such as mail.xxxx.com, which can also be implemented through Java, now, use the Telnet command to send a simple email.

1. Start the black box;

2. enter the Telnet command. If you are prompted that the command does not exist, perform the following operations: start --> control panel --> program --> enable or disable windows --> Telnet client, if "Welcome to Microsoft Telnet client" is displayed, go to the next step;

3. enter Telnet smtp.qq.com 25, which is the SMTP server connected to QQ. The default SMTP port is 25, and other mailboxes can be connected. After the connection is successful, 220 smtp.qq.com esmtp qq mail server is displayed, 220 indicates that the connection is successful;

4. the input of EHLO ghsaumiao is to say hello to the server. I don't know why I didn't directly use hello, but I turned it upside down. I added my own email account to Ehlo;

5. Enter auth login for Logon verification;

6. Enter the email user name. You know it yourself. You do not need to include @ and the following. In addition, you need base64 encryption. How can you encrypt it? There are ready-made applications. Baidu uses base64;

7. Enter the email password, which is also base64 encrypted. If the login succeeds, the system will prompt 235 authentication successful;

8. Enter mail from: <ghsaumiao@qq.com>;

9. Enter rcpt to: <ghsau@163.com>, sent to this mailbox, pay attention to the format must be correct Oh;

10. Enter data to enter the body of the email;

11. Enter from: <ghsaumiao@qq.com>, note that this is after receiving the mail, the displayed mail from where, can be different from the real mailbox Oh;

12. Enter subject: Hello, mail title;

13. Enter a blank line, enter the email content, enter whatever you want, change the line, enter "." To end the content, and enter quit to exit.

14. Enter the inbox of the received email to view the email.

Use the Telnet command to view the email you just sent.

1. Start the black box;

2. Enter Telnet pop3.163.com 110 to connect to the 163 POP3 server. The default POP3 port is 110. After the connection is successful, the following words are displayed: Welcome;

3. Enter user ghsau and user name;

4. Enter pass ********** and the password. encryption is not required here;

5. Enter stat to check the current inbox status. Here, 295 15674926 is displayed, indicating that 295 emails occupy 15674926 bytes;

6. Enter list to view the inbox list;

7. Enter the list number to view the information of an email;

8. Enter the RETR number to view the header and content of an email;

9. Enter quit to exit.

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.