[GH-ISSUE #407] 501 5.5.4 Syntax error in parameters or arguments (invalid SIZE parameter) #264

Closed
opened 2026-03-15 13:31:28 +03:00 by kerem · 8 comments
Owner

Originally created by @baiomys on GitHub (Dec 12, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/407

Something nasty happening while proxying email via Cloudflare.
Two different senders, same result:

DEBU[2024/12/12 14:35:04] [smtpd] response (104.30.10.33) 220 Greta Mailpit (101) ESMTP Service ready
DEBU[2024/12/12 14:35:04] [smtpd] received (104.30.10.33) EHLO ba-dd.cloudflare-email.net
DEBU[2024/12/12 14:35:04] [smtpd] response (104.30.10.33) 250-Greta greets ba-dd.cloudflare-email.net
250-SIZE 0
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
DEBU[2024/12/12 14:35:04] [smtpd] received (104.30.10.33) MAIL FROM:<SRS0=I7TD=ft=sender.ozon.com=mailer@2tg.org> BODY=8BITMIME
ERRO[2024/12/12 14:35:04] [smtpd] response (104.30.10.33) 501 5.5.4 Syntax error in parameters or arguments (invalid SIZE parameter)

DEBU[2024/12/12 14:35:04] [smtpd] received (104.30.10.33) QUIT

Originally created by @baiomys on GitHub (Dec 12, 2024). Original GitHub issue: https://github.com/axllent/mailpit/issues/407 Something nasty happening while proxying email via Cloudflare. Two different senders, same result: ``` DEBU[2024/12/12 14:35:04] [smtpd] response (104.30.10.33) 220 Greta Mailpit (101) ESMTP Service ready DEBU[2024/12/12 14:35:04] [smtpd] received (104.30.10.33) EHLO ba-dd.cloudflare-email.net DEBU[2024/12/12 14:35:04] [smtpd] response (104.30.10.33) 250-Greta greets ba-dd.cloudflare-email.net 250-SIZE 0 250-AUTH LOGIN PLAIN 250 ENHANCEDSTATUSCODES DEBU[2024/12/12 14:35:04] [smtpd] received (104.30.10.33) MAIL FROM:<SRS0=I7TD=ft=sender.ozon.com=mailer@2tg.org> BODY=8BITMIME ERRO[2024/12/12 14:35:04] [smtpd] response (104.30.10.33) 501 5.5.4 Syntax error in parameters or arguments (invalid SIZE parameter) DEBU[2024/12/12 14:35:04] [smtpd] received (104.30.10.33) QUIT ```
kerem closed this issue 2026-03-15 13:31:33 +03:00
Author
Owner

@axllent commented on GitHub (Dec 12, 2024):

I think this may be related to to some (currently) unsupported functionality in the smtpd server in Mailpit (I am investigating, however I just had surgery so I'm on very strong pain medication and my brain isn't functioning properly :)).

I'm fairly sure it has to do with the secondary command in MAIL FROM:<SRS0=I7TD=ft=sender.ozon.com=mailer@2tg.org> BODY=8BITMIME (ie: BODY=8BITMIME) which is causing the error in Mailpit. I need to do a lot of reading before I can comment further.

In the meantime, can you maybe answer a question: do you get this error if you send directly to Mailpit? I'm curious as to whether it is the CloudFlare proxy that is adding that, or your SMTP client.

<!-- gh-comment-id:2539690803 --> @axllent commented on GitHub (Dec 12, 2024): I think this may be related to to some (currently) unsupported functionality in the smtpd server in Mailpit (I am investigating, however I just had surgery so I'm on very strong pain medication and my brain isn't functioning properly :)). I'm fairly sure it has to do with the secondary command in `MAIL FROM:<SRS0=I7TD=ft=sender.ozon.com=mailer@2tg.org> BODY=8BITMIME` (ie: ` BODY=8BITMIME`) which is causing the error in Mailpit. I need to do a lot of reading before I can comment further. In the meantime, can you maybe answer a question: do you get this error if you send directly to Mailpit? I'm curious as to whether it is the CloudFlare proxy that is adding that, or your SMTP client.
Author
Owner

@baiomys commented on GitHub (Dec 12, 2024):

In the meantime, can you maybe answer a question: do you get this error if you send directly to Mailpit?

This weird behavior caused by Cloudflare forwarding in one mailbox to one mailbox rule.
Catch-all rule (many to one) seems working fine and sending mail directly to mailpit works fine.

It does not depend on MTA because I tested two completely different senders.

<!-- gh-comment-id:2539702119 --> @baiomys commented on GitHub (Dec 12, 2024): > In the meantime, can you maybe answer a question: do you get this error if you send directly to Mailpit? This weird behavior caused by Cloudflare forwarding in one mailbox to one mailbox rule. Catch-all rule (many to one) seems working fine and sending mail directly to mailpit works fine. It does not depend on MTA because I tested two completely different senders.
Author
Owner

@axllent commented on GitHub (Dec 13, 2024):

I believe in some cases SMTP relay servers/proxies (in this case CloudFlare) may be adding the BODY=... parameter to assist with message encoding with downstream bounces. Mailpit was originally detecting any parameter as a "size value" which was breaking this. I've pushed a fix for this which is currently in the Docker edge build (unreleased) in case you wanted to test early (if you are able to test please).

Hopefully I will have a new release out by the end of the weekend.

<!-- gh-comment-id:2540439472 --> @axllent commented on GitHub (Dec 13, 2024): I believe in some cases SMTP relay servers/proxies (in this case CloudFlare) may be adding the `BODY=...` parameter to assist with message encoding with downstream bounces. Mailpit was originally detecting any parameter as a "size value" which was breaking this. I've pushed a fix for this which is currently in the Docker edge build (unreleased) in case you wanted to test early (if you are able to test please). Hopefully I will have a new release out by the end of the weekend.
Author
Owner

@baiomys commented on GitHub (Dec 13, 2024):

There is some progress evident.
=)

mailpit       | time="2024/12/13 06:45:44" level=debug msg="[smtpd] received (192.168.5.3) EHLO ba-cci.cloudflare-email.net"
mailpit       | time="2024/12/13 06:45:44" level=debug msg="[smtpd] response (192.168.5.3) 250-lxc-docker greets ba-cci.cloudflare-email.net\r\n250-SIZE 0\r\n250-AUTH LOGIN PLAIN\r\n250 ENHANCEDSTATUSCODES"
mailpit       | time="2024/12/13 06:45:45" level=debug msg="[smtpd] received (192.168.5.3) MAIL FROM:<SRS0=F0GX=gt=ozon.com=notifications@2tg.org> BODY=8BITMIME"
mailpit       | time="2024/12/13 06:45:45" level=debug msg="[smtpd] response (192.168.5.3) 250 2.1.0 Ok"
mailpit       | time="2024/12/13 06:45:46" level=debug msg="[smtpd] received (192.168.5.3) RCPT TO:<~@gate.2tg.org>"
mailpit       | time="2024/12/13 06:45:46" level=error msg="[smtpd] response (192.168.5.3) 503 5.5.1 Bad sequence of commands (MAIL required before RCPT)"
mailpit       | time="2024/12/13 06:45:46" level=debug msg="[smtpd] received (192.168.5.3) QUIT"

REAL message originated NOT from cloudflare was not delivered:

mailpit       | time="2024/12/13 06:50:03" level=debug msg="[smtpd] received (172.16.18.1) MAIL FROM:<prvs=070db6f21=5p@x25.com> SIZE=36179"
mailpit       | time="2024/12/13 06:50:03" level=debug msg="[smtpd] response (172.16.18.1) 250 2.1.0 Ok"
mailpit       | time="2024/12/13 06:50:03" level=debug msg="[smtpd] received (172.16.18.1) RCPT TO:<r00t@sms.tld>"
mailpit       | time="2024/12/13 06:50:03" level=debug msg="[smtpd] response (172.16.18.1) 250 2.1.5 Ok"
mailpit       | time="2024/12/13 06:50:03" level=debug msg="[smtpd] received (172.16.18.1) DATA"
mailpit       | time="2024/12/13 06:50:03" level=debug msg="[smtpd] response (172.16.18.1) 354 Start mail input; end with <CR><LF>.<CR><LF>"

TEST message from sendtestemail WAS delivered:

mailpit       | time="2024/12/13 06:44:40" level=debug msg="[smtpd] received (192.168.5.3) EHLO i-fa.cloudflare-email.net"
mailpit       | time="2024/12/13 06:44:40" level=debug msg="[smtpd] response (192.168.5.3) 250-lxc-docker greets i-fa.cloudflare-email.net\r\n250-SIZE 0\r\n250-AUTH LOGIN PLAIN\r\n250 ENHANCEDSTATUSCODES"
mailpit       | time="2024/12/13 06:44:40" level=debug msg="[smtpd] received (192.168.5.3) MAIL FROM:<SRS0=T5a8=gt=sendtestemail.com=support@2tg.org>"
mailpit       | time="2024/12/13 06:44:40" level=debug msg="[smtpd] response (192.168.5.3) 250 2.1.0 Ok"
mailpit       | time="2024/12/13 06:44:41" level=debug msg="[smtpd] received (192.168.5.3) RCPT TO:<~@gate.2tg.org>"
mailpit       | time="2024/12/13 06:44:41" level=debug msg="[smtpd] response (192.168.5.3) 250 2.1.5 Ok"
mailpit       | time="2024/12/13 06:44:41" level=debug msg="[smtpd] received (192.168.5.3) DATA"
mailpit       | time="2024/12/13 06:44:41" level=debug msg="[smtpd] response (192.168.5.3) 354 Start mail input; end with <CR><LF>.<CR><LF>"
mailpit       | time="2024/12/13 06:44:41" level=debug msg="[smtpd] added missing addresses to Bcc header: ~@gate.2tg.org"
mailpit       | time="2024/12/13 06:44:41" level=debug msg="[db] saved message mFmZugP2uHWgzXYc467SoF (5456 bytes)"

It is obvious that:

  1. result depends on Cloudflare MTA used for mail delivery
  2. delivery of mail containing SIZE=XXXX in MAIL FROM string is broken now
  3. delivery of mail containing BODY=8BITMIME in MAIL FROM still broken

Maybe you should consider splitting MAIL FROM string on "> " or " " delimiter, trimming all spaces and processing list as separate commands?

<!-- gh-comment-id:2540493556 --> @baiomys commented on GitHub (Dec 13, 2024): There is some progress evident. =) ``` mailpit | time="2024/12/13 06:45:44" level=debug msg="[smtpd] received (192.168.5.3) EHLO ba-cci.cloudflare-email.net" mailpit | time="2024/12/13 06:45:44" level=debug msg="[smtpd] response (192.168.5.3) 250-lxc-docker greets ba-cci.cloudflare-email.net\r\n250-SIZE 0\r\n250-AUTH LOGIN PLAIN\r\n250 ENHANCEDSTATUSCODES" mailpit | time="2024/12/13 06:45:45" level=debug msg="[smtpd] received (192.168.5.3) MAIL FROM:<SRS0=F0GX=gt=ozon.com=notifications@2tg.org> BODY=8BITMIME" mailpit | time="2024/12/13 06:45:45" level=debug msg="[smtpd] response (192.168.5.3) 250 2.1.0 Ok" mailpit | time="2024/12/13 06:45:46" level=debug msg="[smtpd] received (192.168.5.3) RCPT TO:<~@gate.2tg.org>" mailpit | time="2024/12/13 06:45:46" level=error msg="[smtpd] response (192.168.5.3) 503 5.5.1 Bad sequence of commands (MAIL required before RCPT)" mailpit | time="2024/12/13 06:45:46" level=debug msg="[smtpd] received (192.168.5.3) QUIT" ``` REAL message originated NOT from cloudflare was not delivered: ``` mailpit | time="2024/12/13 06:50:03" level=debug msg="[smtpd] received (172.16.18.1) MAIL FROM:<prvs=070db6f21=5p@x25.com> SIZE=36179" mailpit | time="2024/12/13 06:50:03" level=debug msg="[smtpd] response (172.16.18.1) 250 2.1.0 Ok" mailpit | time="2024/12/13 06:50:03" level=debug msg="[smtpd] received (172.16.18.1) RCPT TO:<r00t@sms.tld>" mailpit | time="2024/12/13 06:50:03" level=debug msg="[smtpd] response (172.16.18.1) 250 2.1.5 Ok" mailpit | time="2024/12/13 06:50:03" level=debug msg="[smtpd] received (172.16.18.1) DATA" mailpit | time="2024/12/13 06:50:03" level=debug msg="[smtpd] response (172.16.18.1) 354 Start mail input; end with <CR><LF>.<CR><LF>" ``` TEST message from sendtestemail WAS delivered: ``` mailpit | time="2024/12/13 06:44:40" level=debug msg="[smtpd] received (192.168.5.3) EHLO i-fa.cloudflare-email.net" mailpit | time="2024/12/13 06:44:40" level=debug msg="[smtpd] response (192.168.5.3) 250-lxc-docker greets i-fa.cloudflare-email.net\r\n250-SIZE 0\r\n250-AUTH LOGIN PLAIN\r\n250 ENHANCEDSTATUSCODES" mailpit | time="2024/12/13 06:44:40" level=debug msg="[smtpd] received (192.168.5.3) MAIL FROM:<SRS0=T5a8=gt=sendtestemail.com=support@2tg.org>" mailpit | time="2024/12/13 06:44:40" level=debug msg="[smtpd] response (192.168.5.3) 250 2.1.0 Ok" mailpit | time="2024/12/13 06:44:41" level=debug msg="[smtpd] received (192.168.5.3) RCPT TO:<~@gate.2tg.org>" mailpit | time="2024/12/13 06:44:41" level=debug msg="[smtpd] response (192.168.5.3) 250 2.1.5 Ok" mailpit | time="2024/12/13 06:44:41" level=debug msg="[smtpd] received (192.168.5.3) DATA" mailpit | time="2024/12/13 06:44:41" level=debug msg="[smtpd] response (192.168.5.3) 354 Start mail input; end with <CR><LF>.<CR><LF>" mailpit | time="2024/12/13 06:44:41" level=debug msg="[smtpd] added missing addresses to Bcc header: ~@gate.2tg.org" mailpit | time="2024/12/13 06:44:41" level=debug msg="[db] saved message mFmZugP2uHWgzXYc467SoF (5456 bytes)" ``` It is obvious that: 1. result depends on Cloudflare MTA used for mail delivery 2. delivery of mail containing SIZE=XXXX in MAIL FROM string is broken now 3. delivery of mail containing BODY=8BITMIME in MAIL FROM still broken Maybe you should consider splitting MAIL FROM string on "> " or " " delimiter, trimming all spaces and processing list as separate commands?
Author
Owner

@axllent commented on GitHub (Dec 13, 2024):

Damn, that was my mistake, sorry! I have just pushed a fix for the fix. If you don't mind, could you please test again with the latest edge build and let me know if this now resolves the issue for you? Thank you!

<!-- gh-comment-id:2540736964 --> @axllent commented on GitHub (Dec 13, 2024): Damn, that was my mistake, sorry! I have just pushed a fix for the fix. If you don't mind, could you please test again with the latest edge build and let me know if this *now* resolves the issue for you? Thank you!
Author
Owner

@baiomys commented on GitHub (Dec 13, 2024):

You fixed it!
Fantastic, taking into account your current condition.
I am unable to check status of emails containing SIZE in MAIL FROM string, but I hope it will be also okay.
Thanks for quick fix.

<!-- gh-comment-id:2540917128 --> @baiomys commented on GitHub (Dec 13, 2024): You fixed it! Fantastic, taking into account your current condition. I am unable to check status of emails containing SIZE in MAIL FROM string, but I hope it will be also okay. Thanks for quick fix.
Author
Owner

@axllent commented on GitHub (Dec 13, 2024):

Yes, I'm glad to hear it! I'm typing everything with one hand which is really slow - but I have time :) The size argument shouldn't be a problem 👍

<!-- gh-comment-id:2540972971 --> @axllent commented on GitHub (Dec 13, 2024): Yes, I'm glad to hear it! I'm typing everything with one hand which is really slow - but I have time :) The size argument shouldn't be a problem :+1:
Author
Owner

@axllent commented on GitHub (Dec 14, 2024):

This has now been released in v1.21.7.

<!-- gh-comment-id:2543040833 --> @axllent commented on GitHub (Dec 14, 2024): This has now been released in [v1.21.7](https://github.com/axllent/mailpit/releases/tag/v1.21.7).
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#264
No description provided.