[GH-ISSUE #299] POP3 server does not do dot stuffing #201

Closed
opened 2026-03-15 13:09:41 +03:00 by kerem · 6 comments
Owner

Originally created by @henningp on GitHub (May 18, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/299

The POP3 server currently doesn't do "dot stuffing".

From the POP3 spec:

When all lines of the response have been sent, a
final line is sent, consisting of a termination octet (decimal code
046, ".") and a CRLF pair. If any line of the multi-line response
begins with the termination octet, the line is "byte-stuffed" by
pre-pending the termination octet to that line of the response.

In practice, this means that any message line starting with a dot must have an extra dot added at the start of the line. (The same technique is used in SMTP.) Mailpit's POP3 doesn't do this, resulting in dots at the start of lines going missing when getting messages via POP3.

Originally created by @henningp on GitHub (May 18, 2024). Original GitHub issue: https://github.com/axllent/mailpit/issues/299 The POP3 server currently doesn't do "dot stuffing". From the [POP3 spec](https://www.ietf.org/rfc/rfc1939.txt): > When all lines of the response have been sent, a final line is sent, consisting of a termination octet (decimal code 046, ".") and a CRLF pair. _If any line of the multi-line response begins with the termination octet, the line is "byte-stuffed" by pre-pending the termination octet to that line of the response._ In practice, this means that any message line starting with a dot must have an extra dot added at the start of the line. (The same technique is used in SMTP.) Mailpit's POP3 doesn't do this, resulting in dots at the start of lines going missing when getting messages via POP3.
kerem closed this issue 2026-03-15 13:09:47 +03:00
Author
Owner

@axllent commented on GitHub (May 18, 2024):

@henningp - thank you, I did not know this. So if I understand this correctly, a message that contains the following in the returned body (from a POP3 server):

this is a test
.02 test
blaah

would get "translated" (transformed) by any POP3 client to:

this is a test
02 test
blaah

?

In order to address this, we need to prepend a dot on any line that starts with a dot to result in:

this is a test
..02 test
blaah

Am I 100% correct in my understanding?

<!-- gh-comment-id:2118757298 --> @axllent commented on GitHub (May 18, 2024): @henningp - thank you, I did not know this. So if I understand this correctly, a message that contains the following in the returned body (from a POP3 server): ``` this is a test .02 test blaah ``` would get "translated" (transformed) by any POP3 client to: ``` this is a test 02 test blaah ``` ? In order to address this, we need to prepend a dot on any line that starts with a dot to result in: ``` this is a test ..02 test blaah ``` Am I 100% correct in my understanding?
Author
Owner

@henningp commented on GitHub (May 18, 2024):

Hi @axllent, neither did I know about this until this week, and it was a royal pain to debug 😀 Yes, your understanding is exactly correct! Thanks for your swift reply.
I‘m running a patched Mailpit for now with this fix, and that stopped dots from going missing seemingly at random in my tests using POP3.

<!-- gh-comment-id:2118776224 --> @henningp commented on GitHub (May 18, 2024): Hi @axllent, neither did I know about this until this week, and it was a royal pain to debug 😀 Yes, your understanding is exactly correct! Thanks for your swift reply. I‘m running a patched Mailpit for now with this fix, and that stopped dots from going missing seemingly at random in my tests using POP3.
Author
Owner

@axllent commented on GitHub (May 18, 2024):

Thanks so much @henningp - I really appreciate it! I suspect I may have come across this issue before but never worked it out :-)

Your patch looks good (well done) - so I'll merge this soon (I'm just working on something else right now) and get a new release out as soon as I can.

<!-- gh-comment-id:2118781666 --> @axllent commented on GitHub (May 18, 2024): Thanks so much @henningp - I really appreciate it! I suspect I may have come across this issue before but never worked it out :-) Your patch looks good (well done) - so I'll merge this soon (I'm just working on something else right now) and get a new release out as soon as I can.
Author
Owner

@henningp commented on GitHub (May 18, 2024):

Brilliant, thanks! 😊

<!-- gh-comment-id:2118783490 --> @henningp commented on GitHub (May 18, 2024): Brilliant, thanks! 😊
Author
Owner

@axllent commented on GitHub (May 18, 2024):

This has been released in v1.18.3 :) Thanks again for your PR @henningp!

<!-- gh-comment-id:2118801836 --> @axllent commented on GitHub (May 18, 2024): This has been released in v1.18.3 :) Thanks again for your PR @henningp!
Author
Owner

@henningp commented on GitHub (May 18, 2024):

Oh wow, thank you @axllent! :-D

<!-- gh-comment-id:2118807264 --> @henningp commented on GitHub (May 18, 2024): Oh wow, thank you @axllent! :-D
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#201
No description provided.