onsdag 30 maj 2007 23:52 skrev Jeffrey Stedfast: > On Wed, 2007-05-30 at 12:12 +0200, Mads Bondo Dydensborg wrote: > > Hi there > > > > Regrettable I "crashed" into a smtp server today, that does not support ESMTP, > > but only SMTP (some old kind of exchange server, I think). > > > > It seems that System.Net.Mail.SmtpClient only supports ESMTP - is this true? > > Any plans for supporting SMTP also? > > I've just committed a fix to make it work for non-ESMTP servers (as well > as a few fixes for other low-hanging fruit that I spotted while browsing > thru the code).
Fantastic! Thanks a lot. An additional bit of information: Turns out the SMTP server I was talking to, is a piece of anti-virus software running in front of the real mail server. Just to clear Exchange of any accusations on my part. Also, the program I am running is nlog (nlog-project.org) which is compiled to use System.Net.Mail.SmtpClient. Makes a bit annoying to try and use another component. However, your fix does not work with the SMTP "server" I am running against. Here is a stacktrace: 2007-05-31 12:00:15.5294 Error Target exception: System.Net.Mail.SmtpException: 500 Syntax error, command unrecognized at System.Net.Mail.SmtpClient.Authenticate (System.String Username, System.String Password) [0x000a4] in /home/compile/Compile/Mono/mcs/class/System/System.Net.Mail/Smtp Client.cs:678 at System.Net.Mail.SmtpClient.PerformAuthentication () [0x00074] in /home/compile/Compile/Mono/mcs/class/System/System.Net.Mail/SmtpClient.cs:657 at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) [0x000ec] in /home/compile/Compile/Mono/mcs/class/System/System.Net.Mail/SmtpClient.cs:308 The "server" does not support authentication. Looking at the code, it seem there are a couple of FIXME related to this. A question: if the code has to fall back on HELO, can we safely assume that no extensions exists? My understanding of SMTP suggests this. This could be a quick fix for the SMTP case, although auth and other still needs to be determined for the ESMTP case. Attached is a patch against current svn that does exactly this: for ESMTP it assumes that Auth and TLS works (as now), for SMTP it assumes they do not. This fixes my problem (mail is now beeing sent, and received), but is untested on real ESMTP servers (don't have one handy, would require some firewall fiddling). Please let me know if you can accept this almost trivial patch. Regards, Mads > > Jeff > > > _______________________________________________ > Mono-devel-list mailing list > Mono-devel-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-devel-list > > -- Med venlig hilsen/Regards Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo Dydensborg Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77 34
Index: SmtpClient.cs =================================================================== --- SmtpClient.cs (revision 78273) +++ SmtpClient.cs (working copy) @@ -290,6 +290,12 @@ // FIXME: parse the list of extensions so we don't bother wasting // our time trying commands if they aren't supported. + + // Assume that auth and starttls _is_ supported - should still parse + // but otherwise will throw + bool supportsAuth = true; + bool supportsStartTLS = true; + status = SendCommand ("EHLO " + Dns.GetHostName ()); if (IsError (status)) { @@ -297,15 +303,18 @@ if (IsError (status)) throw new SmtpException (status.StatusCode, status.Description); + // Auth and StartTLS is not supported by SMTP + supportsAuth = false; + supportsStartTLS = false; } - if (EnableSsl) { - // FIXME: only attempt this if STARTTLS is supported + if (EnableSsl && supportsStartTLS) { InitiateSecureConnection (); } - // FIXME: only do this if AUTH is supported - PerformAuthentication (); + if (supportsAuth) { + PerformAuthentication (); + } MailAddress from = message.From;
_______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list