Hello,

I can't see another appropriate group to post this in. system.web.mail has a
bad bug in it where it is not conforming to RCF822. The old pre-dotnet
CDONTS obects did not have this behaviour.

The problem is that system.web.mail sends messages with naked line feeds in
them rather than escaping them to be a cr and an lf. An lf on a line by
itself is invalid in an SMTP message.

Repro code is attached below. This message will never be able to be
delivered to a qmail server (of which there are many).

The code is:

using System;
using System.Text;
using System.Web;
using System.Web.Mail;

namespace theEmailTest
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
MailMessage mm = new MailMessage();

mm.BodyEncoding = Encoding.UTF8;

mm.To = "someone@example.microsoft.com";
mm.From = "someone@example.microsoft.com";
mm.Subject = "Test Subject";
mm.BodyFormat = MailFormat.Html;

mm.Body = "Test Body\n\nEnd";

SmtpMail.Send(mm);
}
}
}


The following VBS code does cause the LF characters to be correctly escaped
to a CR + LF pair prior to submitting the message to the local mail queue
for delivery.

Option Explicit

Dim objCDONTS

Set objCDONTS = CreateObject("CDONTS.NewMail")

objCDONTS.To = "someone@example.microsoft.com"
objCDONTS.From = "someone@example.microsoft.com"
objCDONTS.Subject = "Test Subject"
objCDONTS.Body = "Test Body" & chr(10) & chr(10) & "End3"
objCDONTS.Send

Set objCDONTS = Nothing

MsgBox "Done."

Any pointers on getting this fixed?

David.

Re: System.Web.Mail - Bad Bug by Ollie

Ollie
Wed Oct 19 03:49:14 CDT 2005

Is there a reason why you aren't using Environment.NewLine instead of '\n' ?

HTH

Ollie Riches


"David Connors" <davidc@codify.com> wrote in message
news:u0uNtAH1FHA.2132@TK2MSFTNGP15.phx.gbl...
> Hello,
>
> I can't see another appropriate group to post this in. system.web.mail has
> a bad bug in it where it is not conforming to RCF822. The old pre-dotnet
> CDONTS obects did not have this behaviour.
>
> The problem is that system.web.mail sends messages with naked line feeds
> in them rather than escaping them to be a cr and an lf. An lf on a line by
> itself is invalid in an SMTP message.
>
> Repro code is attached below. This message will never be able to be
> delivered to a qmail server (of which there are many).
>
> The code is:
>
> using System;
> using System.Text;
> using System.Web;
> using System.Web.Mail;
>
> namespace theEmailTest
> {
> /// <summary>
> /// Summary description for Class1.
> /// </summary>
> class Class1
> {
> /// <summary>
> /// The main entry point for the application.
> /// </summary>
> [STAThread]
> static void Main(string[] args)
> {
> MailMessage mm = new MailMessage();
>
> mm.BodyEncoding = Encoding.UTF8;
>
> mm.To = "someone@example.microsoft.com";
> mm.From = "someone@example.microsoft.com";
> mm.Subject = "Test Subject";
> mm.BodyFormat = MailFormat.Html;
>
> mm.Body = "Test Body\n\nEnd";
>
> SmtpMail.Send(mm);
> }
> }
> }
>
>
> The following VBS code does cause the LF characters to be correctly
> escaped to a CR + LF pair prior to submitting the message to the local
> mail queue for delivery.
>
> Option Explicit
>
> Dim objCDONTS
>
> Set objCDONTS = CreateObject("CDONTS.NewMail")
>
> objCDONTS.To = "someone@example.microsoft.com"
> objCDONTS.From = "someone@example.microsoft.com"
> objCDONTS.Subject = "Test Subject"
> objCDONTS.Body = "Test Body" & chr(10) & chr(10) & "End3"
> objCDONTS.Send
>
> Set objCDONTS = Nothing
>
> MsgBox "Done."
>
> Any pointers on getting this fixed?
>
> David.
>
>



Re: System.Web.Mail - Bad Bug by David

David
Wed Oct 19 18:04:42 CDT 2005


Ollie Riches wrote:
> Is there a reason why you aren't using Environment.NewLine instead of '\n' ?
>
> HTH

The templates being sent come from external sources and are read in
from files rather than being composited programatically.

Environment.NewLine should presumably return only a line feed character
on UNIX implementations of .NET anyway seeing as that's the native line
termination sequence on UNIX.

I think the bug still stands that system.web.mail should not send mails
that are non-conformant with the relevant RFCs.

David.


Re: System.Web.Mail - Bad Bug by Ollie

Ollie
Thu Oct 20 03:06:35 CDT 2005

I don't have in depth knowledge of the RFC's for this but why don't you use
a regular expression to replace '\n' with the required cr & lf.

HTH

Ollie Riches

"David Connors" <davidc@codify.com> wrote in message
news:1129763081.966630.253910@z14g2000cwz.googlegroups.com...
>
> Ollie Riches wrote:
>> Is there a reason why you aren't using Environment.NewLine instead of
>> '\n' ?
>>
>> HTH
>
> The templates being sent come from external sources and are read in
> from files rather than being composited programatically.
>
> Environment.NewLine should presumably return only a line feed character
> on UNIX implementations of .NET anyway seeing as that's the native line
> termination sequence on UNIX.
>
> I think the bug still stands that system.web.mail should not send mails
> that are non-conformant with the relevant RFCs.
>
> David.
>



Re: System.Web.Mail - Bad Bug by David

David
Thu Oct 20 19:12:17 CDT 2005

Hi Ollie,

We've already done that. I'm posting it here to get the bug fixed in
the framework so we don't have to implement work arounds.

David.