CPJNPOP3Connection
v1.70
Welcome to CPJNPOP3Connection, a freeware C++ class
framework to support
the POP3 (Post Office Protocol v3) protocol. POP3 for those not familiar with all
the internet protocols is the protocol used to retrieve internet email.
References
- For information about POP3 (Post Office
Protocol v3) you should read
RFC 1939.
- RFC 5321 defines the ways standard
headers are used by SMTP/POP3.
- RFC 2110 and
RFC 2557 which covers MHTML
(aka HTML Email).
- Base64 encoding which is used in various places in SMTP/POP3 is described
in RFC 4648
Features
- Simple and clean C++ interface.
- The interface provided is synchronous which provides an easier programming
model than using asynchronous sockets.
- The code does not rely on the MFC socket classes. These classes have a number
of shortcomings, one of which causes problems when they are used in NT services.
- The code can be used in a console application without any problems (Again
this is not the case for the MFC socket classes).
- A configurable timeout for the connection can be set through the class API.
- Supports APOP as well as clear text authentication.
Usage
- The classes are designed for VC 2017 or later. They will not compile on
earlier releases of VC.
- To use the class in your code simply include PJNPOP3.cpp/h, SocMFC.cpp/h
and PJNHash.h in your project and #include PJNPOP3.h in which ever of your
modules needs to make calls to the classes.
- The sockets classes (SocMFC.cpp/h) used by the code are not included in
the zip download and you will need to download these separately these separately from
www.naughter.com/w3mfc.html.
- By default TLS\SSL connections are also provided for. This is provided by the
author's SSLWrappers classes which you will need to download from
http://www.naughter.com/sslwrappers.html.
Please note that the the SSLWrappers classes themselves depends on the author's
CryptoWrappers classes which you will also need to download from
http://www.naughter.com/cryptowrappers.html.
If you do not want to include TLS\SSL support, then you should define the pre-processor
macro "CPJNPOP3_NOSSL" before including PJNPOP3.h.
- Also the PJNHash.h module is not included in the CPJNPOP3Connection zip download
and you will need to download this separately from
www.naughter.com/smtp.html.
- As of v1.66, the code requires that you compile the code using
"/std:c++17".
- To see the class in action, have a look at the code in InitInstance in the
module "main.cpp".
- You will need to initialise Winsock prior to calling any functions
in CPJNPOP3Connection. Depending on your application, this will involve calling
either WSAStartup or AfxSocketInit at start-up of your application.
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
History
v1.70 (27 May 2023)
- Updated copyright details.
- Updated module to indicate that it needs to be compiled using
/std:c++17. Thanks to Martin Richter for reporting this issue.
v1.69 (4 December 2022)
- Fixed an issue in CPJNPOP3Connection::ReadSSLResponse when handling
SEC_I_RENEGOTIATE return values from GetEncryptedMessage.
v1.68 (18 April 2022)
- Updated the code to use C++ uniform initialization for all variable
declarations.
- Reworked CPJNPOP3Buffer::Find to use std::search.
v1.67 (8 January 2022)
- Updated copyright details.
- Updated the code and sample app to support TLS v1.3.
v1.66 (23 April 2021)
- Updated the code to work with the latest version of the hash classes of
the author.
- Updated copyright details.
v1.65 (4 May 2020)
- Fixed more Clang-Tidy static code analysis warnings in the code.
- Updated copyright details.
v1.64 (7 January 2020)
- Updated copyright details.
- Fixed some missing catch statements in the Connect method. Thanks to
Martin Richter for reporting this issue.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.63 (27 December 2019)
- Fixed various Clang-Tidy static code analysis warnings in the code.
v1.62 (2 October 2019)
- Fixed a number of compiler warnings when the code is compiled with VS
2019 Preview
v1.61 (21 April 2019)
- Updated copyright details
- Updated the code to clean compile on VC 2019
- Removed all dependencies on now defunct IDS_PJNPOP3* string resources
v1.60 (4 November 2018)
- Fixed some further C++ core guidelines compiler warnings.
v1.59 (25 June 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
- CPJNPOP3String is now always defined as std::string or std::wstring and
no longer supports CString
v1.58 (18 December 2017)
- Updated the code to compile cleanly when _ATL_NO_AUTOMATIC_NAMESPACE is
defined.
- Removed DTLSv1 as a supported protocol from SSLProtocol enum
v1.57 (12 September 2017)
- Replaced CString::operator LPC*STR() calls throughout the codebase with
CString::GetString calls
v1.56 (29 April 2017)
- Updated the code to compile cleanly using /permissive-.
v1.55 (26 March 2017)
- Updated copyright details.
- Updated the code to clean compile on VC 2017
v1.54 (19 August 2016)
- Updated the code to work with the latest version of the MD5 classes of
the author which can operate in non MFC mode.
- Reworked CPJNPOP3Connection class to be inherited from
SSLWrappers::CSocket. This allows for easier overloading of the various
SSLWrappers class framework virtual functions
- Reworked the CPJNPOP3Exception::GetErrorMessage to not bother putting
the last response into the return error message text.
- Tested the classes support for the APOP command using a free trial
version of the MDaemon Messaging server
v1.53 (27 July 2016)
- Updated code to use new preprocessor define of CWSOCKET_MFC_EXTENSIONS
instead of CWSOCKET_MFC_EXTENSTIONS
- Minor update to the sample project settings to remove _MBCS preprocessor
macro when compiling for Unicode.
v1.52 (12 June 2016)
- Updated the code to compile cleanly on VC 2015
- Updated copyright details.
- Added SAL annotations to all the code
- Reworked the classes to
optionally compile without MFC. By default the classes now use STL classes
and idioms but if you define CWSOCKET_MFC_EXTENSTIONS the classes will
revert back to the MFC behaviour.
v1.51 (23 December 2014)
- Updated the code to use the author's SSLWrappers classes (http://www.naughter.com/sslwrappers.html)
to provide the SSL functionality for PJNPOP3 instead of OpenSSL. Please note
that the SSLWrappers classes itself depends on the author's CryptoWrappers classes
(http://www.naughter.com/cryptowrappers.html)
also. You will need to download both of these libraries and copy their modules
into the PJNPOP3 directory. Also note that the SSLWrappers and CryptoWrapper
classes are only supported on VC 2013 or later and this means that the PJNPOP3
SSL support is only supported when you compile with VC 2013 or later.
- With the change to using SSLWrappers, the code can now support additional
flavours of SSL protocol. They are: SSL v2 on its own, SSL v3 on its own, The
OS SChannel SSL default and AnyTLS. Please see the CPJNPOP3Connection::SSLProtocol
enum for more details. The sample app has been updated to allow these values
to be used and the default enum value is now "OSDefault".
- The default timeout set in the CPJNPOP3Connection constructor is now 60
seconds for both debug and release builds
- The sample app shipped with the source code is now Visual Studio 2008 and
as of this release the code is only supported on Visual Studio 2008 and later.
v1.50 (13 April 2014)
v1.49 (9 February 2014)
- Updated the code to clean compile on VC 2012 & VC 2013.
- Updated copyright details
- Removed all the proxy connection methods as they cannot be easily supported
/ tested by the author.
- The sample app is now linked against the latest OpenSSL v1.0.1f dlls.
- The CPJNPOP3Connection class now provides Set/GetSSLProtocol methods. This
allows client code to specify the exact flavour of SSL which the code should
speak. Supported protocols are SSL v2/v3, TLS v1.0, TLS v1.1, TLS v1.2 and DTLS
v1.0. The default is to use TLS v1.0.
- CPJNPOP3Connection::_Close now provides a bGracefully parameter
- Made more methods virtual to facilitate further client customisation
v1.48 (13 February 2011)
- Updated copyright details
- Updated sample app to clean compile on VC 2010
- Updated code to support latest SSL and Sockets class from the author. This
means that the code now supports IPv6 POP3 servers
- The sample app is now linked against the latest OpenSSL v1.0.0c dlls
- Set/GetBoundAddress have been renamed Set/GetBindAddress for consistency
with the sockets class
v1.47 (22 December 2009)
- Optimized the ReadResponse logic to reduce the amount of searching required
to find the terminator in the received buffer. This helps avoid excessive CPU
utilization when we receive large responses. Thanks to Alexey Rabets for reporting
this issue.
- The size of the read buffer used in the ReadResponse method can now be specified
at runtime via SetReadBufferSize().
- Updated the documentation to fix various out of date details in the API
reference section.
v1.46 (4 May 2009)
- Updated copyright details.
- Updated the sample app's project settings to more modern default values.
- Removed the parsing methods from the CPJNPOP3Message class. For comprehensive
support for message parsing please take a look at CDO for Windows 2000.
- Extensively reworked the parsing code to use CByteArray derived classes
to hold parsed responses instead of CStringA instances. This handles the unusual
but legal situation where a message contains embedded nulls. Thanks to Sergey
Lysenko for reporting this issue.
- Fixed a bug in ReadUIDLResponse when parsing the message ID
- The code in Connect now correctly validates that a timestamp has been provided
if doing APOP authentication
v1.45 (14 June 2008)
- Updated code to compile correctly using _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
define
v1.44 (31 May 2008)
- Code now compiles cleanly using Code Analysis (/analyze)
v1.43 (18 May 2008)
- GetHeaderItem now uses a CStringA parameter instead of CString. Thanks to
Alexey Kuznetsov for reporting this issue.
v1.42 (18 March 2008)
- Updated copyright details
- The code now only supports VC 2005 or later.
- Simplified the response parsing considerably through the usage of CStringA
- Fixed logic which terminates the parsing loop in ReadListResponse
- Improved the robustness of the ReadUIDLResponse parsing logic
- Now includes support for APOP authentication. Thanks to "goodsiwen"
for prompting this update.
v1.41 (31 December 2007)
- Updated sample app to clean compile on VC 2008
- CPJNPOP3Exception::GetErrorMessage now uses the FORMAT_MESSAGE_IGNORE_INSERTS
flag. For more information please see Raymond Chen's blog at
http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx. Thanks
to Alexey Kuznetsov for reporting this issue.
- CPJNPOP3Exception::GetErrorMessage now uses Checked::tcsncpy_s if compiled
using VC 2005 or later.
- Sample app shipped with download is now a VC 2005 solution
v1.40 (21 July 2007)
- Updated copyright details
- CPJNPOP3Connection::Connect, Delete, Statistics, List, UIDL, Reset, Noop
and GetMessageHeader methods now catch CWSocketException exceptions and rethrow
them as CPJNPOP3Exception exceptions. This allows client code to only expect
CPJNPOP3Exception exceptions to be thrown from the class. Thanks to Alexey Kuznetsov
for reporting this issue.
v1.39 (20 November 2006)
- Minor update to the sample app to allow it to clean compile on VC 2005
- Optimized ReadResponse method so that if an error occurs while reading the "RETR"
response, only the actual command text is set into m_sLastCommandResponse instead
of the whole message. This avoids a great performance hit on Unicode projects
because of the m_sLastCommandResponse CString nature (ANSI -> UNICODE conversion).
Thanks to Alexey Kuznetsov for reporting this issue.
v1.38 (9 July 2006)
- Optimized CPJNPOP3Message constructor code.
- Code now uses new C++ style casts rather than old style C casts where necessary.
- Optimized CPJNPOP3Connection constructor code
- All classes now uses exceptions to indicate errors. This means the whole
area of handling errors in the code is a whole lot simpler. You should carefully
review your code as a lot of the return values from methods (especially CPJNPOP3Connection)
are now void and will throw CPJNPOP3Exception's.
- General rework of the class to bring it in line with the author's CPJNSMTPConnection
code
- Update the code in the sample app to TRACE out what it is doing
- Updated the code to clean compile on VC 2005
v1.37 (13 February 2006)
- Fixed a graceful disconnect issue in CPJNPOP3Connection::ReadResponse.
v1.36 (8 February 2006)
- Updated the documentation to use the same style as the web site.
- Removed the unnecessary resource.h from the download zip file.
- Fixed a /Wp64 compile issue in CPJNPOP3Connection::FindMessageID. Thanks
to Alexey Kuznetsov for reporting this issue.
- Updated copyright details.
- Renamed the classes to include a PJN prefix inline with my SMTP class.
- Provided a PJNPOP3_EXT_CLASS to allow the class to be easily added to an
extension dll
- Did a spell check of this document.
- Changed the pre-processor macro to exclude SSL support to be CPJNPOP3_NOSSL.
This is to maintain consistency with my SMTP class.
- Changed the default release mode timeout to 60 seconds and the default debug
mode timeout to 90 seconds. This is to maintain consistency with my SMTP class.
v1.35 (9 April 2005)
- Updated the initialization code for OpenSSL in the sample app to avoid memory
leaks. Thanks to Alexey Kuznetsov for reporting these issues. You should implement
the same initialization and cleanup code in your applications. For details please
check the code in "main.cpp" module which is enclosed in #ifndef POP3_NOSSL_SUPPORT
/ #endif sections.
- "List" function is now public instead of protected. Thanks to
Alexey Kuznetsov for reporting these issues.
- Addition of a simple "FindMessageID" which returns the Message
index given a message ID as returned via UIDL. Thanks to Alexey Kuznetsov for
this addition.
v1.34 (28 March 2005)
- Fixed a number of compiler warnings in the sample app when the code is compiled
with VC .NET 2003.
- Timeout now defaults to 5 seconds in debug mode.
- Added support for connecting via Socks4, Socks5 and HTTP proxies
- Added support for POP3 via SSL. Thanks to Serhiy Pavlov and Alexey Kuznetsov
for suggesting this update. Please note that because I do not have access to
a mail server which provides POP3 over SSL, you should consider this support
preliminary until I get feedback from users of this feature. The standard POP3
support is still fully functional and tested of course.
v1.33 (9 August 2004)
- Fixed a number of compiler warnings when the code is compiled with VC.Net
2003
v1.32 (4 July 2004)
- Added an IsConnected() method to the CPJNPOP3Connection class. Thanks to
Alessandro Rosa for this addition.
- Added two new helper functions, namely CPJNPOP3Message::GetEmailAddress
and CPJNPOP3Message::GetEmailFriendlyName. Thanks to Alessandro Rosa for this
suggestion.
v1.31 (5 June 2004)
- Fixed a bug in CPJNPOP3Connection::ReadResponse, where the wrong parameters
were being null terminated. Thanks to "caowen" for this update.
v1.30 (12 November 2003)
- Fixed a bug in the CPJNPOP3Message operator= method. Thanks to Henrik Grek
for reporting this bug.
v1.29 (6 November 2003)
- Fixed a problem with an unitialized "m_pszMessage" in the CPJNPOP3Message
constructor. Thanks to Michael Gunlock for reporting this problem.
v1.28 (3 November 2003)
- Simplified the code in CPJNPOP3Connection::ReadResponse. Thanks to Clarke
Brunt for reporting this issue.
- Reviewed the various trace statements in the code.
v1.27 (21 July 2003)
- Class now preserves last command response across calls to Disconnect. This
is especially important in calls to Connect when for example you get the POP3
error "-Err. Can't lock the mailbox" or something like this when
you call Connect. Thanks to "Lev Elbert" for reporting this problem
and providing the fix.
v1.26 (5 July 2003)
- Added copy constructors and operator= methods to the CPJNPOP3Message class.
Thanks to "Sten" for pointing out this omission.
- Made destructors of all classes virtual.
29 March 2003
- Initially I was intending adding file attachment support to the class and
numerous people have requested this feature but during my research I came across
a much more fully featured C++ encapsulation of MIME that I could possibly implement.
The project itself is called Mime++ and the URL is
http://www.hunnysoft.com/mimepp/.
The classes provided are nicely implemented in C++ and integrate well with both
MFC and my CPJNPOP3Connection classes. This software is commercial. Alternatively
you could use CDO for Windows 2000 to parse what is returned by the class. I
do not propose to add support for attachments in the future so please no more
emails asking for this!!
v1.25 (29 September 2001)
- Further improved the error handling in CPJNPOP3Connection::ReadResponse
v1.24 (27 September 2001)
- Fixed a bug in CPJNPOP3Connection::ReadResponse when handling disconnection
errors. Thanks to Yuheng Zhao for spotting this problem.
- Improved the error handling in Delete, GetMessageSize & GetMessageID
methods. Thanks to Maxim Y. Melnik for spotting this problem.
v1.23 (11 August 2001)
- Fixed a bug in CPJNPOP3Connection::ReadResponse where determining the terminator
was failing when an embedded NULL was in the message.
v1.22 (27 July 2001)
- Added two methods namely: GetTo() and GetCC() to the CPJNPOP3Message class.
24 March 2001
- Updated the documentation and copyright info.
v1.21 (20 September 2000)
- Fixed a bug in CPJNPOP3Connection::UIDL when message id's were returned
with embedded dots in them. Thanks to Konstantin Vasserman for finding and resolving
this problem.
v1.20 (26 March 2000)
- Fixed a problem where GetBody and GetRawBody will fail if you call it for
a CPJNPOP3Message object that doesn't have a message in it (i.e m_pszMessage
== NULL). This was previously causing a goof old access violation in GetRawBody.
v1.19 (24 August 1999)
- Fixed a bug whereby the function GetHeader was sometimes failing when it
was called when the message was retrieved using the "TOP" command.
v1.18 (5 July 1999)
- Addition of the following functions:
i) CPJNPOP3Message::GetReplyTo()
ii) CPJNPOP3Message::GetRawBody
iii) CPJNPOP3Message::GetSubject
iv)
CPJNPOP3Message::GetFrom
v) CPJNPOP3Message::GetDate
- GetHeaderItem function now uses case insensitive searching.
- GetHeaderItem now allows you to search for the "n'th" header
of a specified type.
v1.17 (29 June 1999)
- Another improvement to GetHeaderItem. When will it end <g>. Originally
this was reported as a bug but upon further investigation it turns out that
the message which was causing the problems had embedded tabs in the header.
This is discouraged by the RFC which refers to mail headers (RFC 822). The code
has been enhanced to handle this case. Thanks to Chris Bishop for spotting this.
- Fix for a bug in GetHeaderItem where I accidentally was using "="
instead of "==". Thanks to Angelini Fabio for spotting this.
- Updated documentation to refer to RFC 822.
v1.16 (27 June 1999)
- Fixed a bug in the GetHeaderItem function when a header spanned multiple
lines as is allowed by RFC 822.
v1.15 (16 June 1999)
- Fixed a bug in the GetHeaderItem function which was causing a header item
which appeared at the beginning of the header fields to fail to be parsed incorrectly.
v1.14 (15 June 1999)
- Added functions to return the message body, header or a particular header
field of a message.
- Tidied up some of the TRACE messages which the code generates.
- Fixed some typos and spelling mistakes in this file.
v1.13 (25 March 1999)
- Fixed a memory leak in the CPJNPOP3Connection::ReadReturnResponse function.
- Now sleeps for 250 ms instead of yielding the time slice. This helps reduce
CPU usage when waiting for data to arrive in the socket
v1.12 (22 February 1999)
- Default timeout for the code when a debug build is built has now been set
to 60 seconds.
- Improved the reading of responses back from the server by implementing a
growable receive buffer.
- Updated instructions on how the relevant RFC documents can be retrieved.
v1.11 (4 January 1999)
- Minor update to the documentation.
- Now includes VC 5 workspace files as standard.
- Properly Unicode enabled all the code as previously the code exposes an
Ascii(LPSTR/LPCSTR) API instead of a TCHAR / CString API.
v1.1 (28 June 1998)
- Fixed a potential buffer overflow problem in Delete and Retrieve functions
when a large message number was specified.
- Improve the ReadResponse code by
- a) passing the readability check onto the socket class
and
- b) Sleeping for 100 ms prior to looping around waiting
for new response data
- Classes are now fully Unicode compliant. Unicode build configurations are
also now included.
- Now supports the TOP POP3 command which can be issued using the GetHeader
function.
- Fixed a few typos in the documentation.
v1.0 (18 May 1998)
API Reference
The API consists of the public member functions of the class CPJNPOP3Connection
Connect
Disconnect
Statistics
Delete
GetMessageSize
GetMessageID
Retrieve
Reset
UIDL
GetMessageHeader
Noop
GetLastCommandResponse
GetTimeout
SetTimeout
GetReadBufferSize
SetReadBufferSize
CPJNPOP3Connection::Connect
void CPJNPOP3Connection::Connect(LPCTSTR pszHostName,
LPCTSTR pszUser, LPCTSTR pszPassword,
int nPort = 110, AuthenticationMethod am
= AUTH_PLAIN, BOOL bSSL = FALSE);
Parameters
pszHostName The network address of the socket to connect to: a machine
name such as “mail.yourisp.com”, or a dotted number such as “128.56.22.8”.
pszUser This is the POP3 user name of the mailbox.
pszPassword This is the password for the POP3 mailbox.
nPort This is the port number on which to connect. The default value
is 110 which is the default POP3 port number.
am The authentication method to use. Choices are AUTH_PLAIN which corresponds
to using the "USER / PASS" commands or AUTH_APOP which uses the APOP challenge
/ response command.
bSSL If compiled to support SSL, then setting this value will cause the connection
to be made over a SSL connection instead of in the clear.
Remarks
Call this member function to establish a connection to a POP3 mailbox.
See Also
CPJNPOP3Connection::Disconnect
CPJNPOP3Connection::Disconnect
void CPJNPOP3Connection::Disconnect(BOOL
bGracefully
= TRUE);
Parameters
bGracefully TRUE if the "QUIT" command should be issued to the
POP3 server before closing the connection.
Remarks
The corollary function of Connect.
See Also
CPJNPOP3Connection::Connect
CPJNPOP3Connection::Statistics
void CPJNPOP3Connection::Statistics(int& nNumberOfMails,
int& nTotalMailSize);
Parameters
nNumberOfMails Upon a successful return this will contain the number
of mails waiting in the mailbox.
nTotalMailSize Upon a successful return this will contain the size in
bytes (aka Octets) of all mails waiting in the mailbox.
Remarks
Retrieves the statistics for the Mailbox by issuing the "STAT" command.
See Also
CPJNPOP3Connection::GetMessageSize
CPJNPOP3Connection::Delete
void CPJNPOP3Connection::Delete(int nMsg);
Parameters
nMsg The message number of the message to delete. This value starts
at 1.
Remarks
Marks a message as "to be deleted" by issuing the "DELE"
command.
See Also
CPJNPOP3Connection::Reset
CPJNPOP3Connection::GetMessageSize
DWORD CPJNPOP3Connection::GetMessageSize(int nMsg);
Return Value
Upon a successful return this will contain the size in bytes of the
specified message.
Parameters
nMsg The message number of the message to retrieve the size of.
Remarks
Retrieves the size of a specified message. Internally this will issue the "LIST"
command if required.
See Also
CPJNPOP3Connection::Retrieve
CPJNPOP3Connection::GetMessageID
CPJNPOP3String CPJNPOP3Connection::GetMessageID(int nMsg);
Return Value
Upon a successful return this will contain the ID of the specified
message as a string.
Parameters
nMsg The message number of the message to retrieve the ID of.
Remarks
Retrieves the ID of a specified message. Internally this will issue the "UIDL"
command if required. As "UIDL" is an optional POP3 command, your client
app should handle the return value if it is to correctly work on all POP3 servers.
See Also
CPJNPOP3Connection::UIDL
CPJNPOP3Connection::Retrieve
void CPJNPOP3Connection::Retrieve(int nMsg,
CPJNPOP3Buffer& message);
Parameters
nMsg The message number of the message to retrieve the size of.
message Upon a successful return this will contain the POP3 messages.
This class is a simple derivation of the MFC CByteArray class
Remarks
Retrieves the specified message by issuing the "RETR" command.
See Also
CPJNPOP3Connection::GetMessageSize
CPJNPOP3Connection::GetMessageHeader
void CPJNPOP3Connection::GetMessageHeader(int nMsg,
CPJNPOP3Buffer& message);
Parameters
nMsg The message number of the message to retrieve the header of.
message Upon a successful return this will contain the POP3 message
header.
Remarks
Retrieves the header of a specified message. Internally this will issue the "TOP"
command if required. As "TOP" is an optional POP3 command, your client
app should handle the return value if it is to correctly work on all POP3 servers.
See Also
CPJNPOP3Connection::GetMessage
CPJNPOP3Connection::Reset
void CPJNPOP3Connection::Reset();
Parameters
None.
Remarks
Resets all messages which were previously marked as deleted. i.e. it undoes the
work of all the DELE commands in this session. For further information about how
messages are deleted in POP3, please refer to the RFC.
See Also
CPJNPOP3Connection::Delete
CPJNPOP3Connection::UIDL
void CPJNPOP3Connection::UIDL();
Parameters
None.
Remarks
Sends the "UIDL" command which retrieves the ID for a specified message.
As "UIDL" is an optional POP3 command, your client app should handle the
return value if it is to correctly work on all POP3 servers.
See Also
CPJNPOP3Connection::GetMessageID
CPJNPOP3Connection::Noop
void CPJNPOP3Connection::Noop();
Parameters
None.
Remarks
Issues a "NOOP" command to the server.
CPJNPOP3Connection::GetLastCommandResponse
CPJNPOP3String CPJNPOP3Connection::GetLastCommandResponse() const;
Return Value
The last command response from the server as a string.
Parameters
None.
Remarks
The CPJNPOP3Connection class can return additional text information along with
most errors. This extended error information can be retrieved by using the GetLastCommandResponse
function after an unsuccessful function call. An example of this is if the Connect
function failed because of a validation problem, GetLastCommandResponse could return
something like "-ERR Access is denied". GetLastCommandResponse can be
called multiple times until another CPJNPOP3Connection function is called which
sends a POP3 command.
CPJNPOP3Connection::GetTimeout
DWORD CPJNPOP3Connection::GetTimeout() const;
Return Value
The timeout in milliseconds which the code will wait for responses
from the POP3 server.
Parameters
None.
Remarks
Since CPJNPOP3Connection provides a synchronous API, a timeout mechanism is provided.
By default the value is 2 seconds in release mode and 20 seconds in debug mode.
The value is larger in debug mode so that the code does not time out when you are
debugging it.
See Also
CPJNPOP3Connection::SetTimeout
CPJNPOP3Connection::SetTimeout
void CPJNPOP3Connection::SetTimeout(DWORD dwTimeout)
Return Value
None.
Parameters
dwTimeout The new timeout value in milliseconds.
Remarks
Sets the timeout to use for connections to the POP3 server.
See Also
CPJNPOP3Connection::GetTimeout
CPJNPOP3Connection::GetReadBufferSize
DWORD CPJNPOP3Connection::GetReadBufferSize() const;
Return Value
The buffer size to use for receiving responses from the POP3 server.
Parameters
None.
Remarks
By default this value is 1024 bytes.
See Also
CPJNPOP3Connection::SetReadBufferSize
CPJNPOP3Connection::SetReadBufferSize
void CPJNPOP3Connection::SetReadBufferSize(DWORD dwReadBufferSize)
const;
Return Value
None.
Parameters
dwReadBufferSize The buffer size to use in bytes.
Remarks
The corollary function to GetReadBufferSize.
See Also
CPJNPOP3Connection::GetReadBufferSize
Contacting the Author
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
27 May 2023