Poco Release 1.5.2 and pop3 - bug when retrieve Mail?!

Please post support and help requests here.
Posts: 4
Joined: 21 Feb 2014, 12:17

Poco Release 1.5.2 and pop3 - bug when retrieve Mail?!

Postby PocoProject » 21 Feb 2014, 12:49


I am using the Poco Release 1.5.2 (2013-09-16)
as a static version in my C++-project.

Now I have problems getting mails via pop3
(in HTML-format) from gmx.

The following code works ONLY, if I get mails which were sent in plain-text.
If I try to get HTML-Mails, I get an exception!

Code: Select all

#include "main.hpp"
using namespace std;
using namespace Poco::Net;
using namespace Poco;

int main()
    string host = "pop.gmx.com";
    int port    = 110;
    string user = "xxx@gmx.de";
    string pass = "xxx";
    try {
        POP3ClientSession session(host, port);
        session.login(user, pass);
        POP3ClientSession::MessageInfoVec messages;
        for(POP3ClientSession::MessageInfoVec::iterator it = messages.begin(); it != messages.end(); ++it)
            MailMessage message;
            session.retrieveMessage((*it).id, message);  //here is the critical entry-point!!
    catch (POP3Exception &e)
      cerr << e.displayText() << endl;
    catch (NetException &e)
      cerr << e.displayText() << endl;

    return 0;

Output - Exception:
terminate called after throwing an instance of 'Poco::NotFoundException'
what(): Not found

After some debugging, I think the error is in the following
line in the MailMessage.cpp of poco.

If the header has NO Key named MailMessage::HEADER_CONTENT_TRANSFER_ENCODING,
then there is thrown the exception at the overloaded []-operator in
the NameValueCollection.cpp.

I dumped the header-array for my plain-text mail and for my HTML-mail
(sent by ms-outlook) and for the HTML-mail I coudn't find the

Is it a bug ? ...and if it is, will u fix it in the beta-release?

Code: Select all

 void handlePart(const MessageHeader& header, std::istream& stream)
                        /// Handles a part. If message pointer was provided at construction time,
                        /// the message pointed to will be properly populated so it could be written
                        /// back out at a later point in time.
                        std::string tmp;
                        Poco::StreamCopier::copyToString(stream, tmp);
                        if (_pMsg)

                                MailMessage::ContentTransferEncoding cte = MailMessage::ENCODING_7BIT;
                                std::string enc = header[MailMessage::HEADER_CONTENT_TRANSFER_ENCODING];  //CRASH HERE!
                                if (enc == MailMessage::CTE_8BIT)
                                        cte = MailMessage::ENCODING_8BIT;
                                else if (enc == MailMessage::CTE_QUOTED_PRINTABLE)
                                        cte = MailMessage::ENCODING_QUOTED_PRINTABLE;
                                else if (enc == MailMessage::CTE_BASE64)
                                        cte = MailMessage::ENCODING_BASE64;

Code: Select all

const std::string& NameValueCollection::operator [] (const std::string& name) const
        ConstIterator it = _map.find(name);
        if (it != _map.end())
                return it->second;
                throw NotFoundException(name);

Posts: 11
Joined: 05 Mar 2013, 13:58

Re: Poco Release 1.5.2 and pop3 - bug when retrieve Mail?!

Postby cristiantm » 22 Feb 2014, 14:15

I do not have a computer with development env. to test this now, but at
http://www.w3.org/Protocols/rfc1341/5_C ... oding.html

These values are not case sensitive. That is, Base64 and BASE64 and bAsE64 are all equivalent. An encoding type of 7BIT requires that the body is already in a seven-bit mail- ready representation. This is the default value -- that is, "Content-Transfer-Encoding: 7BIT" is assumed if the Content-Transfer-Encoding header field is not present

So, Poco should default to 7-bit if there is no content transfer encoding header on the mail. Looks like it is defaulting to 7bit BUT also looks like there is no check if the header exists.

I suggest you open an issue on github (https://github.com/pocoproject/poco/issues/new) with a link to this post and/or with this information. And as you are a developer, maybe also fork and push a fix suggestion, if you wish. Anyway a Poco developer or another community contributor (like me and maybe you :) ) might find some time to fix it and then it can get into next releases :). Looks like a simple fix, just checking if the header exists before getting its value seems to be a good fix.

Return to “Support”

Who is online

Users browsing this forum: No registered users and 2 guests