Checking for the End of a Mail Message
POP3 mail messages are terminated by <period> contained on a line by itself. When your application gets a mail drop via an RWSocketPortal, which can be obtained through the portal method of an RWPop3DataReply, it should not look for more data if the termination character is found.
To handle the possibility that a mail message might have a single period on a line, POP3 servers double any period that is the first character in a line. You can use the Internet Basics global function rwRemovePeriods() to replace double periods with single periods.
Example 23 – Removing extra periods
#include "rw/internet/util.h"
 
void
saveMessage (RWPop3Client client)
{
RWPop3DataReply reply;
reply = client.retr(1); // retrieve the first message
RWPortalIStream istr(reply.portal()); // construct input stream
RWCString body;
body.readFile(istr);
body = rwRemovePeriods(body);
ofstream ostr("save.me"); // construct output stream in save.me
RWStreamCoupler couple;
couple(istr, ostr, pop3StreamFilter);
}