Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: invalid bare carriage return or newline. #129

Closed
x8x opened this issue Feb 14, 2024 · 5 comments
Closed

Error: invalid bare carriage return or newline. #129

x8x opened this issue Feb 14, 2024 · 5 comments

Comments

@x8x
Copy link

x8x commented Feb 14, 2024

After upgrading to 0.9 I got a few mail delivery errors like this:

Delivery has failed permanently for your email to:
	..
No further deliveries will be attempted.
Error during the last delivery attempt:
	writing message as smtp data: invalid bare carriage return or newline, transient
Reporting-MTA: dns; ..

Thinking this commit was a related fix, I upgraded to version v0.0.10-0.20240209102133-ee1db2dde705, but am still getting such delivery errors.

./mox reparse returns these errors:

Reparsing account A...
parsing message 388: quotedprintable: invalid bytes after =: "\r\r\n" (continuing)
244 message(s) reparsed for account A

Reparsing account B...
parsing message 2809: quotedprintable: invalid bytes after =: "\r\r\n" (continuing)
parsing message 2936: quotedprintable: invalid bytes after =: "\r\r\n" (continuing)
parsing message 3334: quotedprintable: invalid bytes after =: "\r\r\n" (continuing)
parsing message 3422: quotedprintable: invalid bytes after =: "\r\r\n" (continuing)
1454 message(s) reparsed for account B

Reparsing account C...
parsing message 4786: first boundary cannot be finishing boundary (continuing)
parsing message 4893: first boundary cannot be finishing boundary (continuing)
586 message(s) reparsed for account C

How to fix stored messages reported by reparse and are there still known issues related to the smtp error above?

Thank you!

@mjl-
Copy link
Owner

mjl- commented Feb 14, 2024

Thinking this commit was a related fix, I upgraded to version v0.0.10-0.20240209102133-ee1db2dde705, but am still getting such delivery errors.

That's an error you are stilling getting for new incoming deliveries? Or is that coming from mox parsing the message from disk? It is still possible that mox rejects messages, but I'm thinking we should accept such messages if they are incoming for final delivery, and only keep rejecting them for messages that still need to be delivered (over submission).

The bug was that the smtpserver was adding an extra \r to the message file. Reparse only reads the message as stored on disk, it doesn't fix it. Could you try removing that \r from the on-disk file yourself and running reparse again? If that works, we may need some subcommand or instructions to fix up these issues...

@x8x
Copy link
Author

x8x commented Feb 14, 2024

That's an error you are stilling getting for new incoming deliveries? Or is that coming from mox parsing the message from disk? It is still possible that mox rejects messages, but I'm thinking we should accept such messages if they are incoming for final delivery, and only keep rejecting them for messages that still need to be delivered (over submission).

Got this two days ago, after upgrading mox to v0.0.10-0.20240209102133-ee1db2dde705:

Delivery has been delayed of your email to:

	user@gmail.com

Next attempts to deliver: in 4 hours, 8 hours and 16 hours.
If these attempts all fail, you will receive a notice.

Error during the last delivery attempt:

	writing message as smtp data: invalid bare carriage return or newline, transient
Reporting-MTA: dns; mail.server.com
Arrival-Date: 12 Feb 2024 22:32:47 +0000

Final-Recipient: rfc822;user@gmail.com
Action: delayed
Status: 4.0.0
Remote-MTA: dns;alt4.gmail-smtp-in.l.google.com ([173.194.202.26])
Diagnostic-Code: smtp; 4.0.0 (writing message as smtp data: invalid bare carriage return or newline, transient)
Last-Attempt-Date: 13 Feb 2024 00:24:44 +0000
Will-Retry-Until: 14 Feb 2024 04:24:44 +0000
Content-Type: multipart/alternative;
	boundary=".."
Mime-Version: 1.0
..

The bug was that the smtpserver was adding an extra \r to the message file. Reparse only reads the message as stored on disk, it doesn't fix it. Could you try removing that \r from the on-disk file yourself and running reparse again? If that works, we may need some subcommand or instructions to fix up these issues...

Had a quick go at it but it seams I am unable to locate it, will need to figure out the proper tooling, I welcome any suggestions.
But then, that would probably only fix the stored messages but not fix the delivery issues.

What about this error:

parsing message 4786: first boundary cannot be finishing boundary (continuing)

Thank you!

@x8x
Copy link
Author

x8x commented Feb 14, 2024

Ok, I was able to fix the mails with \r\r\n and deleted those reporting first boundary cannot be finishing boundary.

Now mox reparse returns no errors.

Will be watching for new deliveries returninginvalid bare carriage return or newline, transient errors.

mjl- added a commit that referenced this issue Feb 16, 2024
we weren't properly tracking the cr's and lf's when being strict about message
lines when sending data.

we are reading buffered data from a Reader. if that chunk happens to start with
a newline, we weren't looking at the previously written data, which could be a
cr. instead, in that case, we would always claim the cr/lf wasn't correct.

the new test case triggered the behaviour before having the fix.

should solve issue #129 by x8x, thanks for the report!
@mjl-
Copy link
Owner

mjl- commented Feb 16, 2024

I think I found the bug that was causing error message writing message as smtp data: invalid bare carriage return or newline that was failing to deliver outgoing messages. See commit message for the details.

Still good to keep this issue open for the reparse and "\r\r\n" issue.

@mjl-
Copy link
Owner

mjl- commented Mar 9, 2024

v0.0.10 is coming soon. It has instructions for fixing the "\r\r\n" issue. Closing this issue, but feel free to reopen if needed.

@mjl- mjl- closed this as completed Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants