Page 1 of 1

Remote server replied: 501 Syntax error - line too long

Posted: 2014-07-21 17:26
by ICTSUS
I'm getting bounced messages from a number of email service providers (in particular 1and1 Internet) which say:

Error Type: SMTP
Remote server (xxx.xxx.xx.xxx) issued an error.
hMailServer sent: .
Remote server replied: 501 Syntax error - line too long

A little research indicates that the recipient server is using a mail filter with one of the filters looking at the line length and in particular, the number of continuous characters. This is becoming increasingly common as a way to filter out SPAM emails and is standard on a number of Firewalls, such as Foxguard.

I can find no way of limiting the number of characters that HMail server will allow in outgoing emails and I wondered if anyone had experienced this problem and has worked out how to circumvent it?

I have had limited success by persuading the sender to resend using text only emails. Does anyone have any other solution?

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2014-07-21 18:18
by percepts
the email RFCs stipulate that a TEXT line length must not be more than 1000 characters long and also that all lines must be terminated with CRLF (chr13 & chr 10) leaving 998 characters for TEXT line content.

IN VB this can be added by appending VBCrLF to end each line. In PHP by appending \r\n to end each line. In other languages by appending chr 13 chr 10 to each line.

So either your user is creating line endings which are not correctly formatted, typically by only adding LF and and not CRLF or they are assuming that because its HTML (which doesn't require line endings in a browser rendering engine) that they don't need them. But email servers are NOT browser rendering engines. They are MTAs which have different rules (RFCs) and HTML can be considered as TEXT lines.

So tell your user that whatever they are using to create the HTML in their mails, it should append CRLF to the end of each HTML line or at a minimum after each <br> and/or </p> so that they don't build massive TEXT line lengths. But even then it could fail with a lonth paragraph.

ALSO

tell them that they need to use the correct MIME type for HTML which might help. But it's their software so its upto them to get it right and not for us to debug their badly written code for them. Modern email clients don't cause this problem.

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2014-07-21 18:39
by ICTSUS
percepts wrote:the email RFCs stipulate that a TEXT line length must not be more than 1000 characters long and also that all lines must be terminated with CRLF (chr13 & chr 10) leaving 998 characters for TEXT line content.

IN VB this can be added by appending VBCrLF to end each line. In PHP by appending \r\n to end each line. In other languages by appending chr 13 chr 10 to each line.

So either your user is creating line endings which are not correctly formatted, typically by only adding LF and and not CRLF or they are assuming that because its HTML (which doesn't require line endings in a browser rendering engine) that they don't need them. But email servers are NOT browser rendering engines. They are MTAs which have different rules (RFCs) and HTML can be considered as TEXT lines.

So tell your user that whatever they are using to create the HTML in their mails, it should append CRLF to the end of each HTML line or at a minimum after each <br> and/or </p> so that they don't build massive TEXT line lengths. But even then it could fail with a lonth paragraph.

ALSO

tell them that they need to use the correct MIME type for HTML which might help. But it's their software so its upto them to get it right and not for us to debug their badly written code for them. Modern email clients don't cause this problem.
Thanks for that - their software is Outlook 2010.

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2014-07-21 19:18
by percepts
ICTSUS wrote:Thanks for that - their software is Outlook 2010.
It might be but it's how they construct the email that matters. e.g pasting in a big chunk of HTML from elsewhere which is isn't correctly formatted.

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2014-07-21 19:33
by ICTSUS
percepts wrote:
ICTSUS wrote:Thanks for that - their software is Outlook 2010.
It might be but it's how they construct the email that matters. e.g pasting in a big chunk of HTML from elsewhere which is isn't correctly formatted.
Now that's an interesting point. I have concerns about their signature. I will look at that and see if it is the issue.

It's actually a regular email though, with an attached spreadsheet. There were no problems when sending via an Exchange Server, only when sent via hMailServer. Curious.

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2014-07-21 20:00
by percepts
in hmailadmin / settings / protocols / smtp / rfc compliance tab

do you have allow incorrectly formatted line endings ticked or not ?

I'm not sure if that test is done on outgoing mail or only incoming but untick it and try sending mail again. It could be it gets rejected by hmail and sender is notified immediately. (If that is the cause of 1&1 rejections)

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2014-07-21 20:04
by ICTSUS
percepts wrote:in hmailadmin / settings / protocols / smtp / rfc compliance tab

do you have allow incorrectly formatted line endings ticked or not ?

I'm not sure if that test is done on outgoing mail or only incoming but untick it and try sending mail again. It could be it gets rejected by hmail and sender is notified immediately. (If that is the cause of 1&1 rejections)

I look at that prior to posting and it WAS ticked, but it's now unticked. I'll try it again.

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2015-02-26 12:26
by asifrao
I am having exactly same issue with 1&1. My iOS app is using an open source library, https://code.google.com/p/skpsmtpmessage/ to send email.

Where I am sending an image as an attachment, image size is 108K. Email goes fine to gmail, and other accounts but bounced back with following error

[Return Code 501] sid: wy2c1p0063WXimb01 :: Syntax error - line too long

also mail delivery system send attached file that has long text, with following header


From:xxxxx
To:xxxx
Content-Type: multipart/mixed; boundary=SKPSMTPMessage--Separator--Delimiter
Mime-Version: 1.0 (SKPSMTPMessage 1.0)
Subject:xxxx

--SKPSMTPMessage--Separator--Delimiter
Content-Disposition: attachment;
filename="file.png"
Content-Type: image/jpeg;
x-unix-mode=0644;
name="file.png"
Content-Transfer-Encoding: base64

If I reduce the image size to 4K, it works fine.

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2015-02-26 12:30
by ICTSUS
It seems the signature IS the problem - they have a large chunk of HTML in it. I changed it, and the problem went away.

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2015-04-29 09:35
by ibuhmailuser
ICTSUS wrote:It seems the signature IS the problem - they have a large chunk of HTML in it. I changed it, and the problem went away.
Hi,

we have stumbled on this problem, too.
If we set a domain HTML signature we get a "line too long" from some servers:

Code: Select all

Error Type: SMTP
Remote server (xxx.xxx.xxx.xxx) issued an error.
hMailServer sent: .
Remote server replied: 500 Line too long
The signature only contains a link with an image in it and no line break (total length is 144 characters).
As soon as we remove it the problem doesn't seem to appear, but our customer needs the domain HTML signature...

How does hMailServer attach the signature to the mail? Does it just append it to the message or does it append a line break before/in the message with the appended signature?

Re: Remote server replied: 501 Syntax error - line too long

Posted: 2015-04-29 09:45
by jimimaseye
Show us the FULL HTML that is in the signature (copy and paste - you can obfuscate text if you want as long as you use matching character counts).