POP3 provides a class interface to a POP3 session. Basically it encapsulates in C++ classes the fundamental things you do with a connection to a POP3 server. Here's how you use an object of type POP3: More...
#include <pop3.h>
Classes | |
struct | Attachment |
struct | Body |
struct | Header |
struct | Impl |
struct | Message |
struct | User |
sets connect status to not_connected More... | |
Public Types | |
enum | constants { ok, connected, not_connected, connect_failed, last_constant } |
typedef std::string | string |
typedef std::list< string > | stringlist_t |
typedef std::list< User > | userlist_t |
Public Member Functions | |
char const * | connect (string server, string user, string password) |
int | connect_status () const |
If connection is successful, you a null pointer returned. Otherwise you get a pointer to an error message. This function not only connects to the server, it also downloads all the messages. If an error occurs at any time in this process, the status of the session goes back to not_connected. | |
void | disconnect () |
Returns one of: | |
char const * | message_body (size_t message_number, Body **header) |
Get a pointer to the header for a given message. If successful, the pointer will be returned and the message_header() function will return 0. Otherwise, this function will return an error message. | |
char const * | message_header (size_t message_number, Header **header) |
size_t | messages () const |
Returns count of available messages. | |
POP3 () | |
~POP3 () | |
Private Attributes | |
Impl * | impl_ |
Actual implementation type. |
POP3 provides a class interface to a POP3 session. Basically it encapsulates in C++ classes the fundamental things you do with a connection to a POP3 server. Here's how you use an object of type POP3:
include <pop3>
...
POP3 session;
char const *error = session.connect("server", "userid", "password");
if(error) cout << "Connect error is " << error << endl; else {
size_t message_count = session.messages();
POP3::Header* h;
error = session.message_header(4, &h);
if(error) cout << "Error retrieving header for message 4, " << error << endl; else { cout << "Subject of message 4 is " << h->subject_ << endl; }
POP3::Body* b;
error = session.message_body(4, &b);
if(error) cout << "huh? Why does message 4 not have a body: " << error << endl; else for(size_t i; i < b->lines_.size(); ++i) cout << "Line " << i << ": b->lines_[i] << endl;
}
When serious errors occur, the session's connect status goes to 'not_connected', or 'connect_failed'. Queries for non-existent messages do not cause this, but io errors do cause it.
Definition at line 37 of file pop3.h.
typedef std::list<string> stringlist_t |
typedef std::list<User> userlist_t |
enum constants |
int connect_status | ( | ) | const |
If connection is successful, you a null pointer returned. Otherwise you get a pointer to an error message. This function not only connects to the server, it also downloads all the messages. If an error occurs at any time in this process, the status of the session goes back to not_connected.
void disconnect | ( | ) |
char const * message_body | ( | size_t | message_number, | |
Body ** | header | |||
) |
Get a pointer to the header for a given message. If successful, the pointer will be returned and the message_header() function will return 0. Otherwise, this function will return an error message.
Definition at line 157 of file pop3.cxx.
char const * message_header | ( | size_t | message_number, | |
Header ** | header | |||
) |
size_t messages | ( | ) | const |