Exclamation marks being inserted into Emails at approx 1000 character mark

Have a .NET program that uses the System.Net.Main namespace to send an email via SMTP.

Its on a customers site so from there it will go via a (series of?) SMTP relay servers before it reaches its destination.

At the moment I have no information about this smtp replay / email infrastructure (and getting that information is going to be hard).

Somewhere along the line an exclamation mark is being inserted into long URL's in the the email around 100 chars in from the start of a line.

EDIT- Actually have found its about 1000 chars in

This is not happening on a test system or hundreds of other sites.

I feel sure this has to be something to do with escape codes to break long lines up.

Anyone got any ideas?


Solution 1:

Got hit with this myself.

If you are building a html message without any carriage returns in it, you may get errors somewhere around the 1000 character mark.

Solution is to add a few \r\n characters so that each line is smaller than 1000 (or 988 if you don't count the \r\n characters).

See section 2.1.1. Line Length Limits of RFC 2822 for more details:

2.1.1. Line Length Limits

There are two limits that this standard places on the number of characters in a line. Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.