#include <inetmail.h>
Inheritance diagram for PPOP3Client:
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 |
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;
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.
virtual PBoolean PPOP3Client::Close | ( | ) | [virtual] |
Close the socket, and if connected as a client, QUITs from 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.
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.
PUnsignedArray PPOP3Client::GetMessageSizes | ( | ) |
Get an array of a integers representing the sizes of each of the messages in the mail box.
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.
PBoolean PPOP3Client::BeginMessage | ( | PINDEX | messageNumber | ) |
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.
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.
Reimplemented from PIndirectChannel.
PBoolean PPOP3Client::loggedIn [protected] |
PString PPOP3Client::apopBanner [protected] |