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

501 5.5.4 Syntax error in parameters or arguments (invalid SIZE parameter) #407

Closed
baiomys opened this issue Dec 12, 2024 · 8 comments
Closed

Comments

@baiomys
Copy link

baiomys commented Dec 12, 2024

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:<[email protected]> 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

@axllent
Copy link
Owner

axllent commented 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:<[email protected]> 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.

@baiomys
Copy link
Author

baiomys commented 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.

@axllent
Copy link
Owner

axllent commented 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.

@baiomys
Copy link
Author

baiomys commented 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:<[email protected]> 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:<[email protected]>"
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:<[email protected]> 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:<[email protected]>"
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:<[email protected]>"
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:<[email protected]>"
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: [email protected]"
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?

@axllent
Copy link
Owner

axllent commented 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!

@baiomys
Copy link
Author

baiomys commented 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.

@axllent
Copy link
Owner

axllent commented 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 👍

@axllent
Copy link
Owner

axllent commented Dec 14, 2024

This has now been released in v1.21.7.

tmeijn pushed a commit to tmeijn/dotfiles that referenced this issue Dec 20, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [axllent/mailpit](https://github.com/axllent/mailpit) | patch | `v1.21.6` -> `v1.21.8` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>axllent/mailpit (axllent/mailpit)</summary>

### [`v1.21.8`](https://github.com/axllent/mailpit/blob/HEAD/CHANGELOG.md#v1218)

[Compare Source](axllent/mailpit@v1.21.7...v1.21.8)

##### Chore

-   Update node dependencies
-   Update Go dependencies

##### Fix

-   **db:** Remove unused FOREIGN KEY REFERENCES in message_tags table ([#&#8203;374](axllent/mailpit#374))

### [`v1.21.7`](https://github.com/axllent/mailpit/blob/HEAD/CHANGELOG.md#v1217)

[Compare Source](axllent/mailpit@v1.21.6...v1.21.7)

##### Chore

-   Update node dependencies
-   Update Go dependencies
-   Bump Go version for automated testing
-   Move smtpd & pop3 modules to internal
-   Stricter SMTP 'MAIL FROM' & 'RCPT TO' handling ([#&#8203;409](axllent/mailpit#409))
-   Display "To" details in mobile messages list
-   Display "From" details in message sidebar (desktop) ([#&#8203;403](axllent/mailpit#403))

##### Fix

-   Ignore unsupported optional SMTP 'MAIL FROM' parameters ([#&#8203;407](axllent/mailpit#407))
-   Prevent splitting multi-byte characters in message snippets ([#&#8203;404](axllent/mailpit#404))

##### Testing

-   Add smtpd tests

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS42NC4wIiwidXBkYXRlZEluVmVyIjoiMzkuNzUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
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