Web lists-archives.com

Re: Help Reading from a POP3 Mail Server

On 07 Dec 2018, at 20:04, John <john.iliffe@xxxxxxxxx> wrote:

> Tim, FYI, the problem I encountered during testing using a few hundred 

> emails randomly grabbed off the server, was that someone had sent an

> e-mail where they delimited a copy/paste operation with a string of dots.

> Since these were all alone on the line they matched the ./n/r sequence

> when I tested for end of e-mail.


> The problem with any approach that relies on testing the received data

> is likely to be ambiguities like this. The server, based on looking at

> the received stream, just sends until it gets to EOF, sends the . 

> delimiter and stops. fgets() and fread() don't seem to spot this until

> the socket times out.

The server (not sure whether your local one or the remote sender's one) is supposed to do dot-stuffing to get round this, as I noted. You then have to do dot-unstuffing to restore the original. See the code I posted.

Cheers -- Tim