Results 1 to 3 of 3

Thread: Communicate w/ POP3 Server

  1. #1

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    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:
    1. Winsock1.SendData "USERmidgetsbro"
    2. Do Until DoneSending = True 'the donesending variable is changed in the SendComplete event of the Winsock control
    3.      DoEvents
    4. Loop
    5. DoneSending = False
    6. Winsock1.SendData "PASSmypassword"
    7. Do Until DoneSending = True
    8.      DoEvents
    9. Loop
    10. Winsock1.SendData "GET" & 'I dunno what to put here to get email, I know it works like this for FTP
    11. 'etc.

    Thanks to anyone who responds
    <removed by admin>

  2. #2
    sunnyl
    Guest
    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.

  3. #3

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Thank you so much sunnyl. Just what I needed. You are a genius!
    <removed by admin>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width