Remote server replied: 501 Syntax error - line too long

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
ICTSUS
New user
New user
Posts: 5
Joined: 2014-07-21 17:17

Remote server replied: 501 Syntax error - line too long

Post by ICTSUS » 2014-07-21 17:26

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?

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

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

Post by percepts » 2014-07-21 18:18

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.

ICTSUS
New user
New user
Posts: 5
Joined: 2014-07-21 17:17

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

Post by ICTSUS » 2014-07-21 18:39

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.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

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

Post by percepts » 2014-07-21 19:18

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.

ICTSUS
New user
New user
Posts: 5
Joined: 2014-07-21 17:17

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

Post by ICTSUS » 2014-07-21 19:33

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.

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

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

Post by percepts » 2014-07-21 20:00

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)

ICTSUS
New user
New user
Posts: 5
Joined: 2014-07-21 17:17

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

Post by ICTSUS » 2014-07-21 20:04

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.

asifrao
New user
New user
Posts: 1
Joined: 2015-02-26 12:14

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

Post by asifrao » 2015-02-26 12:26

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.

ICTSUS
New user
New user
Posts: 5
Joined: 2014-07-21 17:17

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

Post by ICTSUS » 2015-02-26 12:30

It seems the signature IS the problem - they have a large chunk of HTML in it. I changed it, and the problem went away.

ibuhmailuser
New user
New user
Posts: 1
Joined: 2015-04-17 15:40

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

Post by ibuhmailuser » 2015-04-29 09:35

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?

User avatar
jimimaseye
Moderator
Moderator
Posts: 7360
Joined: 2011-09-08 17:48

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

Post by jimimaseye » 2015-04-29 09:45

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).
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Post Reply