PPOP3Client Class Reference

#include <inetmail.h>

Inheritance diagram for PPOP3Client:

PPOP3 PInternetProtocol PIndirectChannel PChannel PObject List of all members.

Public Types

enum  LoginOptions { AllowUserPass = 1, UseSASL = 2, AllowClearTextSASL = 4 }

Public Member Functions

 PPOP3Client ()
 ~PPOP3Client ()
virtual PBoolean Close ()
PBoolean LogIn (const PString &username, const PString &password, int options=AllowUserPass)
int GetMessageCount ()
PUnsignedArray GetMessageSizes ()
PStringArray GetMessageHeaders ()
PBoolean BeginMessage (PINDEX messageNumber)
PBoolean DeleteMessage (PINDEX messageNumber)

Protected Member Functions

PBoolean OnOpen ()

Protected Attributes

PBoolean loggedIn
PString apopBanner

Detailed Description

A TCP/IP socket for the Post Office Protocol version 3.

When acting as a client, the procedure is to make the connection to a remote server, then to retrieve a message using the following procedure:


      PPOP3Client mail;
      if (mail.Connect("popserver")) {
        if (mail.LogIn("Me", "password")) {
          if (mail.GetMessageCount() > 0) {
            PUnsignedArray sizes = mail.GetMessageSizes();
            for (PINDEX i = 0; i < sizes.GetSize(); i++) {
              if (mail.BeginMessage(i+1))
                mail.Read(myMessage, sizes[i]);
              else
                PError << "Error getting mail message." << endl;
            }
          }
          else
            PError << "No mail messages." << endl;
        }
        else
           PError << "Mail log in failed." << endl;
      }
      else
         PError << "Mail conection failed." << endl;
      


Member Enumeration Documentation

enum PPOP3Client::LoginOptions

Enumerator:
AllowUserPass  Allow the use of the plain old USER/PASS if APOP or SASL are not available
UseSASL  Use SASL if the AUTH command is supported by the server
AllowClearTextSASL  Allow LOGIN and PLAIN mechanisms to be used.


Constructor & Destructor Documentation

PPOP3Client::PPOP3Client (  ) 

Create a TCP/IP POP3 protocol socket channel. The parameterless form creates an unopened socket, the form with the address parameter makes a connection to a remote system, opening the socket. The form with the socket parameter opens the socket to an incoming call from a "listening" socket.

PPOP3Client::~PPOP3Client (  ) 

Destroy the channel object. This will close the channel and as a client, QUIT from remote POP3 server.


Member Function Documentation

virtual PBoolean PPOP3Client::Close (  )  [virtual]

Close the socket, and if connected as a client, QUITs from server.

Returns:
PTrue if the channel was closed and the QUIT accepted by the server.

Reimplemented from PIndirectChannel.

PBoolean PPOP3Client::LogIn ( const PString username,
const PString password,
int  options = AllowUserPass 
)

Log into the POP server using the mailbox and access codes specified.

Returns:
PTrue if logged in.
Parameters:
username  User name on remote system.
password  Password for user name.
options  See LoginOptions above

int PPOP3Client::GetMessageCount (  ) 

Get a count of the number of messages in the mail box.

Returns:
Number of messages in mailbox or -1 if an error occurred.

PUnsignedArray PPOP3Client::GetMessageSizes (  ) 

Get an array of a integers representing the sizes of each of the messages in the mail box.

Returns:
Array of integers representing the size of each message.

PStringArray PPOP3Client::GetMessageHeaders (  ) 

Get an array of a strings representing the standard internet message headers of each of the messages in the mail box.

Note that the remote server may not support this function, in which case an empty array will be returned.

Returns:
Array of strings continaing message headers.

PBoolean PPOP3Client::BeginMessage ( PINDEX  messageNumber  ) 

Parameters:
messageNumber  Number of message to retrieve. This is an integer from 1 to the maximum number of messages available.

PBoolean PPOP3Client::DeleteMessage ( PINDEX  messageNumber  ) 

Delete the message specified from the mail box.

Returns:
Array of strings continaing message headers.

PBoolean PPOP3Client::OnOpen (  )  [protected, virtual]

This callback is executed when the Open() function is called with open channels. It may be used by descendent channels to do any handshaking required by the protocol that channel embodies.

The default behaviour is to simply return PTrue.

Returns:
Returns PTrue if the protocol handshaking is successful.

Reimplemented from PIndirectChannel.


Member Data Documentation

PBoolean PPOP3Client::loggedIn [protected]

PString PPOP3Client::apopBanner [protected]


The documentation for this class was generated from the following file:
Generated on Mon Feb 23 01:57:57 2009 for PTLib by  doxygen 1.5.1