Parsing a message

Since the MIME format is text, one might need to create an email message from a string.

#include <cstdlib>
#include <string>
#include <mailio/message.hpp>


using std::string;
using mailio::message;
using mailio::mime_error;
using mailio::message_error;
using mailio::codec_error;


int main()
{
    try
    {
        string msg_str = "From: mail io <address@mailio.dev>\r\n"
            "To: mailio <address@mailio.dev>\r\n"
            "Subject: Zdravo, Svete!\r\n"
            "Date: Thu, 11 Feb 2016 22:56:22 +0000\r\n"
            "\r\n"
            "Hello, World!\r\n";
        message msg;
        msg.parse(msg_str);
    }
    catch (const mime_error& exc)
    {
        // handle the mime error
    }
    catch (const message_error& exc)
    {
        // handle the message error
    }
    catch (const codec_error& exc)
    {
        // handle the encoding/decoding error
    }
    
    return EXIT_SUCCESS;
}
The headers found in the text are populated, as well the message body.