9

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?

1
  • Found out its not 100 chars into a link, its approx 1000 chars into the message. This gives more info but still mystery why only ever reported by one customer. Perhaps some smtp servers are more tolerant than others? systemwebmail.com/faq/4.4.5.aspx
    – Ryan
    Sep 4, 2009 at 20:12

3 Answers 3

11

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.

4
  • Thanks - also see discussions on this post - systemwebmail.com/faq/4.4.5.aspx
    – Ryan
    Sep 4, 2009 at 21:27
  • RFC-2822-2.1.1 seems to be more guidance and advice rather than an enforced rule. Outlook seems to be affected. Some other email clients are not affected by this.
    – YoYo
    Oct 25, 2018 at 6:01
  • @YoYo I would say Each line of characters MUST be no more than 998 characters would be a rule , but and SHOULD be no more than 78 characters, would be more guidance and advice rather than a rule.
    – sgmoore
    Oct 25, 2018 at 8:53
  • Yeah the wording doesn’t allow that flexibility. I have to agree.
    – YoYo
    Oct 25, 2018 at 9:24
0

Wrapping at a certain number of characters is usually a client issue. If you're not seeing it at your other sites, or on a test machine I don't think its your code. See if you can't find out what client is being used to receive the message-it could be some crufty old thing thats auto wrapping at a certain number of characters.

0

It does not sound like the .Net app is causing the issue if the problem is not happening on many other sites where the same code is running. Is the problem site behind some kind of application firewall or anti-spam device that might be monitoring the smtp stream? If so, there might be a rule about truncating long URLs that is being triggered which then causes the URLs in the email to be shortened.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .