Skip to content

POP3 client may not detect server's APOP capability #529

Description

@jpmerkel

This is a minor issue, considering APOP is so old and outdated, but I noticed APOP did not work with my mail server. The code in Pop3Engine.cs expects the <timestamp> to appear right after the +OK in the server's greeting, but that is not required per RFC 1939. The example on page 16 of the RFC shows it at the end of the line:

S: +OK POP3 server ready <1896.697170952@dbc.mtview.ca.us>
C: APOP mrose c4c9334bac560ecc979e58001b3e22fb
S: +OK maildrop has 1 message (369 octets)

Here is a snippet from the MailKit protocol log from my test:

Connected to pop://10.20.42.23:110/?starttls=when-available
S: +OK mail.test POP3 ready <F201706231210.AA102635MD1932@mail.test>
C: CAPA
S: +OK Capability list follows
S: TOP
S: USER
S: UIDL
S: .
C: USER frank@mail.test
S: +OK frank@mail.test... User ok
C: PASS *********
S: +OK frank@mail.test's mailbox has 1 total messages (4826 octets)

It went straight to USER without attempting APOP.

Changing the code in Pop3Engine.cs from this:

            index = text.IndexOf('>');
            if (text.Length > 0 && text[0] == '<' && index != -1) {
                ApopToken = text.Substring(0, index + 1);
                Capabilities |= Pop3Capabilities.Apop;
            }

to this:

            index = text.IndexOf('<');
            if (index != -1) {
                int index2 = text.IndexOf('>', index + 1);
                if (index2 != -1) {
                    ApopToken = text.Substring(index, index2 - index + 1);
                    Capabilities |= Pop3Capabilities.Apop;
                }
            }

fixes it for me.

Here's a protocol log snippet afterwards:

Connected to pop://10.20.42.23:110/?starttls=when-available
S: +OK mail.test POP3 ready <F201706231403.AA0326161MD4798@mail.test>
C: CAPA
S: +OK Capability list follows
S: TOP
S: USER
S: UIDL
S: .
C: APOP frank@mail.test 22f8e98cabe32c27fa273f049ae13a61
S: +OK frank@mail.test's mailbox has 1 total messages (4826 octets)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions