|
-
Nov 25th, 2001, 12:09 AM
#1
Thread Starter
PowerPoster
Communicate w/ POP3 Server
What are the commands to send to the POP3 server to log in and get the e-mail? Is it the same was as using FTP, like
VB Code:
Winsock1.SendData "USERmidgetsbro"
Do Until DoneSending = True 'the donesending variable is changed in the SendComplete event of the Winsock control
DoEvents
Loop
DoneSending = False
Winsock1.SendData "PASSmypassword"
Do Until DoneSending = True
DoEvents
Loop
Winsock1.SendData "GET" & 'I dunno what to put here to get email, I know it works like this for FTP
'etc.
Thanks to anyone who responds
-
Nov 25th, 2001, 01:57 AM
#2
This is 60 pages from the RFCs compressed into several paragraphs for your convenience!
Communicating with POP is very easy. However, commands need to be sent in order:
Once you connect, you will receive a welcome message from the POP3 server preceeded by +OK
1) Send: USER username vbCrLf
If the username is accepted, server will reply with +OK
2) Send: PASS password vbCrLf
If the password is accepted, server will reply with +OK
3) Send: STAT vbCrLf
Server will return: +OK A B
where A is the number of new messages, and B is the total size of the emails in bytes.
4) To get an email, send: RETR X vbCrLf
where X is the number of the email. Eg, RETR 1 will return the first email in the inbox. You find the number of emails in the inbox by the reply in the STAT command. The server will then send you the email data. It sends it in multiple chunks and the end of the email is signaled by: vbCrLf.vbCrlf (carriage return line feed period carriage return line feed).
Be careful here when trying to detect the EOM (end of message). Even though the EOM is only 5 bytes in size (and trust me from experience), even the five bytes might be sent into two or more chunks.
After an email is received, you can close the connection by sending: QUIT
and the server will reply with +OK.
Note that in all cases, +OK can be replaced by -ERR if the server thinks there is an error and the details of the error will follow the -ERR in the same string.
To delete an email, send: DELE X
where X is the number of the email to delete.
There are also some other commands like UIDL (which returns a unique ID for each email in the inbox). But the above process are the bare minimums implemented by all POP3 clients and servers.
Enjoy.
-
Nov 25th, 2001, 02:14 AM
#3
Thread Starter
PowerPoster
Thank you so much sunnyl. Just what I needed. You are a genius!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|