-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Bounces from multiple providers due to 501 5.5.4 Syntax error in BODY parameter #37
Comments
Hi Chris, this is hard to narrow down, since it's a little bit "black magic" on what's happening on the recipient server end. Since this only happens for some recipients, I assume that it's some hard limit, that some mail servers still allow and some are more strict on. I've checked the mail server EHLO messages of the different domains and they all seem to use the same mail server software. At first glance, this might be due to the attachment. By default go-mail uses Base64 encoding for attachments. The base64 encoder of Go does not limit the length of the output, so the attachments might have long lines, which might not correspond with RFC 5322 2.1.1 - which describes a maximum line length. For testing purpose, I've created a new branch https://github.com/wneessen/go-mail/tree/37-bugfix in which I've changed the attachment encoding to quoted printable, which will make sure that lines are split at ~78 char length. Could you download that branch and try again or alternatively, if that is not easy to accomplish, remove the attachment from your code for testing purpose, so we can easily see if the attachment length is causing the issue? If that is the case, I have a better understanding of what is happening and can implement a patch accordingly. |
By default, the encoding/base64 in Go does not add line breaks to its output. This patch introduces the Base64LineBreaker which satisfies the io.WriteCloser interface Attachments are now correctly broken up into maximum of 76 chars
Hi again Chris, please disregard my previous message. I've meanwhile implemented a proper |
Thanks! I bet that will fix it. I've rebuilt my app and deployed it. It sends out ~80 emails per night so I should know by tomorrow. I'll keep you updated. |
@chriselkins How did the last batch go? Any further bounces? |
I haven't received any bounces this week. I think we're good to go and this issue can be closed. Thanks for taking care of this! |
Great to hear that. Closing the issue for now. |
Description
Some domains we are sending to are producing bounces with : "501 5.5.4 Syntax error in BODY parameter". We've also had an instance of "550 Maximum line length exceeded (see RFC 5322 2.1.1).". The plain text message we are sending is static and I've ensured every line is less than 78 characters long. The emails we send do contain a PDF attachment. At first I thought it may be something in our HTML template so we have since switched to only sending plain text emails and are still seeing the issue. Emails to Google and lot's of other domains are not bouncing.
Relevant code (removed error handling and redacted email addresses only):
In go.mod and go.sum:
The values of the relevant variables mentioned above are read from this TOML file:
Domains we are seeing bounces from:
yadtel.net, eplus.net, windstream.net, lawlessupholstery.com, comporium.net
Examples of the bounces:
Example of email successfully received at a Google account -- contents copied from the "Show Original" option in Gmail:
To Reproduce
We're running the app on a customer's Windows server; we build and develop on Linux.
We have run
go get -u github.com/wneessen/go-mail
to ensure we are on latest version of lib.The app is built with:
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o invoice-generator.exe
Expected behaviour
No bounces due to syntax error in body.
Screenshots
No response
Attempted Fixes
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: