karastojko / mailio

mailio is a cross platform C++ library for MIME format and SMTP, POP3 and IMAP protocols. It is based on standard C++ 17 and Boost library.
Other
374 stars 98 forks source link

imap::append failing #107

Closed mbsteixeira closed 1 year ago

mbsteixeira commented 2 years ago

Mail message method ::append operation fails when there are attached files. I implemented the move_message function using the "COPY " statement. It is horrible, but it runs ok for my purpose.

void imap::move_message(const std::string& folder_from_name, const std::string& folder_dest_name, const std::string& mail_id) { int tryCm1 = 1; select(folder_from_name); string cmd1 = "COPY " + mail_id + " " + folder_dest_name; string cmd2 = "COPY " + mail_id + " INBOX." + folder_dest_name; retry_oper: _dlg->send(format(tryCm1==1? cmd1 : cmd2));

string line = _dlg->receive();
tag_result_response_t parsed_line = parse_tag_result(line);
if (parsed_line.result == tag_result_response_t::OK)
{
    _dlg->send(format("CLOSE"));
    string line = _dlg->receive();
    tag_result_response_t parsed_line = parse_tag_result(line);
    return;
}
if (tryCm1 == 1)
{
    tryCm1 = 2;
    goto retry_oper;
}
_dlg->send(format("CLOSE"));
throw imap_error("Parsing failure."+ parsed_line.response);

};

I added these two changes, too : void message::subject_charset( const std::string& charset) { _subject.charset = charset;

}

void message::subject(const string& mail_subject) { _subject.buffer = mail_subject; if (_subject.charset == codec::CHARSET_ASCII) { _subject.charset = codec::CHARSET_ASCII; if (codec::is_utf8_string(_subject.buffer)) _subject.charset = codec::CHARSET_UTF8; } }

karastojko commented 2 years ago

Can you please create a PR for this suggestion?

mbsteixeira commented 2 years ago

Yes, after improving the code I will make the PR.

karastojko commented 1 year ago

No PR to confirm the issue.