Kitura / Swift-SMTP

Swift SMTP client
Apache License 2.0
255 stars 59 forks source link

Mail declined by recipient: Syntax error - line too long #106

Open LinusGeffarth opened 4 years ago

LinusGeffarth commented 4 years ago

I cannot send emails to some email addresses. They are rejected with the following message:

Syntax error - line too long

and some more info from here:

Action: failed Status: 5.0.0 Remote-MTA: DNS; mx-ha02.web.de [212.227.17.8] Diagnostic-Code: SMTP; 501 Syntax error - line too long Last-Attempt-Date: Final-Log-ID: i04d66w419XirMM

Any idea what I need to do?

evitiello commented 3 years ago

I receive the same type of issue when sending an HTML attachment. The mail arrives, but it is truncated and has the following in the header:

Sun-Java-System-SMTP-Warning: Lines longer than SMTP allows found and truncated.

mbarnach commented 3 years ago

@LinusGeffarth Could you provide an example of mail and address that is declined? Could it be declined by the receiving server (as the error message suggested)?

LinusGeffarth commented 3 years ago

It is declined by the receiving server, yes. That's why I can still send to some email addresses, while I cannot send to others. Unfortunately, it's been a while since this issue occurred so I'm not sure I'll find that email...what exactly do you need? The Leaf view? Or the raw email?

mbarnach commented 3 years ago

I was looking for a way to reproduce it. I've also found that the maximum length for a line should be 998 (1000+CR LF). This StackOverflow thread shows the same issue and the solution. You could add that to your content. If you come up with a good/generic solution, feel free to submit a PR!

LinusGeffarth commented 3 years ago

Yeah that 998 chars per line was probably the issue. However, I was not able to reduce line lengths, because just making shorter HTML in the Leaf views didn't help.

mbarnach commented 3 years ago

Could it be the CR LF that was not using the right encoding? In that case, we will need to have a way to reproduce it in order to fix it...

LinusGeffarth commented 3 years ago

I'll see if I can grab a copy of the email I tried to send. In which form do you need it? The email itself, or the Leaf view, or something else?

mbarnach commented 3 years ago

The raw text should do it.