Use Telnet to send and receive mail (with bat automatically sent code)

Source: Internet
Author: User
Tags auth base64

take 163 mailbox as an example →→→→→→→telnet receive mail



Note: All response +ok (OK) or-err (NO)

1. Connection →telnet pop.163.com 110

2. Username →user * * *

3. Password →pass * * *

4. After verifying OK, the terminal will display the following information:
+ok (s) [72208371 byte (s)]
The number 60 indicates 60 messages, and 72208371 indicates the total number of bytes (i.e. 72208371B) of the 60 messages.

The commands you can use are as follows:

1.stat command format: stat without parameters

Stat command, view statistics, after execution, the POP3 server responds with a correct answer, starting with "+ok", followed by two digits, the first is the number of messages, and the second is the size of the message.

2.list command format: list [n] parameter n optional, n for message number

List command, viewing the mailing list, you can get the number of each message by using the list command without parameters, and each message is displayed in one line, the number in front is the number of the message, and the following number is the size of the message.

3.UIDL command format: UIDL [n] parameter n optional, n for message number

UIDL command, same as list, but display message information more detailed than list, more specific

4.RETR command format: retr n parameter n not province, N for message number

RETR command to view the contents of a message

5.dele command format: Dele n parameter n not province, N for message number

Dele command to delete the specified message (Note: The dele n command simply deletes the message, only after the QUIT command is executed, the message is actually deleted)

6.top command format: Top N m parameter n,m not province, N for message number, m for line number

Top command, read the number of lines of the specified message body, and if m=0, read only the header of the message

7.noop command format: noop without parameters

NoOp command, after the command is issued, the POP3 server does nothing and returns only one correct response to "+ok"

8.quit command format: quit without parameters

Quit command, after the command is issued, Telnet disconnects from the POP3 server and the system goes into an updated state

--------------------------------------------------------------------------------


take 163 mailbox as an example →→→→→→→telnet send mail


1. Connection →telnet smtp.163.com 25
echo "220"

2. Application word (casually write) →helo Vkill
echo "OK"

3. Login mode (This is the general login mode) →auth Login
echo "334 Dxnlcm5hbwu6"

(Note: At this time the user and password are Base64 encoded characters, no BASE64 encoded encryption on hand, I provide an online: http://www.yx127.com/base64.html)

4. User name →****
echo "334 Ugfzc3dvcmq6"

5. Password →****
echo "235 authentication successful" means validation passed

6. Sender →mail from: <xxxxx@163.com >
echo "Mail OK"

7. Recipient →rcpt to: <xxxxx@56.com >
echo "Mail OK"

8. Start writing body →data
Enter the body content is OK, the body to conform to the MIME specification
Example:
Sender of from:xxxxx@163.com← Email
to:xxxxx@56.com← e-Mail Recipient
cc:xxxxx@56.com← recipients who receive CC-Sent messages
Subject:test← the subject of an e-mail message
Version of the Mime-version:1.0←mime protocol
content-type:text/plain← Message Format Text

Hello vkill← content

When the line is entered. Return, echo "OK" sent successfully

9. Disconnect the connection →quit

--------------------------------------------------------------------------------

Take 163 mailbox As an example, use the. bat file to automatically invoke Telnet to send the message.

--------------------------------------------------------------------------------

Based on the above principle, we will then have a bat to automatically send the message, instead of a line to manually enter the command ... The code is as follows:

Echo Set Sh=wscript.createobject ("Wscript.Shell") >telnet_tmp.vbs Echo Wscript.Sleep >>telnet_tmp.vbs Echo Sh. SendKeys "Open smtp.163.com 25{enter}" >>telnet_tmp.vbs echo wscript.sleep 1000 >>telnet_tmp.vbs echo Sh. SendKeys "Helo abc{enter}" >>telnet_tmp.vbs echo Wscript.Sleep >>telnet_tmp.vbs echo Sh. SendKeys "Auth Login{enter}" >>telnet_tmp.vbs echo Wscript.Sleep >>telnet_tmp.vbs echo Sh. SendKeys "!! youusername!! {ENTER} ' >>telnet_tmp.vbs echo wscript.sleep >>telnet_tmp.vbs echo Sh. SendKeys "!! youpassword!! {ENTER} ' >>telnet_tmp.vbs echo wscript.sleep >>telnet_tmp.vbs echo Sh. SendKeys "Mail From:<xxxxx@163.com>{enter}" >>telnet_tmp.vbs echo wscript.sleep >>telnet_ Tmp.vbs echo Sh. SendKeys "Rcpt To:<xxxxx@163.com>{enter}" >>telnet_tmp.vbs echo wscript.sleep >>telnet_tmp.vbs Echo Sh. SendKeys "Data{enter}" >>telnet_tmp.vbs echo wscript.sleep >> telnet_tmp.vbs echo Sh. SendKeys "Mail subject!!!! {ENTER} {ENTER} ' >>telnet_tmp.vbs echo sh. SendKeys "Message content!!!! {ENTER} ' >>telnet_tmp.vbs echo sh. SendKeys ". {ENTER} ' >>telnet_tmp.vbs start Telnet cscript//nologo telnet_tmp.vbs del telnet_tmp.vbs

Where the red part can be changed. Tested, available ...

In fact, the code can be simpler. Just look at you bat master how did the O (∩_∩) o haha ~

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.