The problem is with .NET 2.0!
System.Net does not send proper smtp authentication commands, or at least not for the smtp server that I use.
The AUTH LOGIN command is not supposed to be followed by anything however .NET and apparently all of Microsoft's smtp servers send AUTH LOGIN username where username is in base-64. This results in no authentication taking place and as a result I can't send mail. I can however send mail from an ASP page using good-ole CDOSYS.
I had A LOT of trouble finding this information so will include the resources that I finally found here for others.
There is a post on MSDN forums about it which helped me out a great deal.(http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=365462&SiteID=1)
First I needed to setup SMTP logging to do this I added the following "code" to the web.config file of my DotNetNuke site. I found this information here: http://www.systemnetmail.com/faq/4.10.aspx (there is an error in the sample they provide)
This has to go AFTER </configSections>.
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log in Windows Forms projects.-->
<source name="Microsoft.VisualBasic.Logging.Log.WindowsFormsSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
<source name="System.Net">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Mail">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
<add name="System.Net.Mail" value="Verbose" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.1200.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<add name="System.Net"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="System.Net.log"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
This will result in a file called System.Net.log in the root of your DotNetNuke install.
The log you will get should look something like this (ugly): (Red indicates where the problem is)
System.Net Information: 0 : [1148] Associating MailMessage#11337845 with Message#15010670
System.Net Verbose: 0 : [1148] SmtpClient::.ctor()
System.Net Information: 0 : [1148] Associating SmtpClient#39722444 with SmtpTransport#53537015
System.Net Verbose: 0 : [1148] Exiting SmtpClient::.ctor() -> SmtpClient#39722444
System.Net Verbose: 0 : [1148] SmtpClient#39722444::Send(MailMessage#11337845)
System.Net Information: 0 : [1148] SmtpClient#39722444::Send(DeliveryMethod=Network)
System.Net Information: 0 : [1148] Associating SmtpClient#39722444 with MailMessage#11337845
System.Net Information: 0 : [1148] Associating SmtpTransport#53537015 with SmtpConnection#63356977
System.Net Information: 0 : [1148] Associating SmtpConnection#63356977 with ServicePoint#40420562
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Socket(InterNetwork#2)
System.Net.Sockets Verbose: 0 : [1148] Exiting Socket#3881099::Socket()
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Connect(18:25#306750871)
System.Net.Sockets Verbose: 0 : [1148] Exiting Socket#3881099::Connect()
System.Net Information: 0 : [1148] Associating SmtpConnection#63356977 with SmtpPooledStream#29918630
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Receive()
System.Net.Sockets Verbose: 0 : [1148] Data from Socket#3881099::Receive
System.Net.Sockets Verbose: 0 : [1148] 00000000 : 32 32 30 20 62 67 6D 70-6F 6D 72 32 2E 73 61 73 : 220 bgmpomr2.sas
System.Net.Sockets Verbose: 0 : [1148] 00000010 : 6B 6E 65 74 2E 73 6B 2E-63 61 20 2D 2D 20 53 65 : knet.sk.ca -- Se
System.Net.Sockets Verbose: 0 : [1148] 00000020 : 72 76 65 72 20 45 53 4D-54 50 20 28 53 61 73 6B : rver ESMTP (Sask
System.Net.Sockets Verbose: 0 : [1148] 00000030 : 54 65 6C 20 65 4D 65 73-73 61 67 69 6E 67 20 53 : Tel eMessaging S
System.Net.Sockets Verbose: 0 : [1148] 00000040 : 65 72 76 69 63 65 29 0D-0A : ervice)..
System.Net.Sockets Verbose: 0 : [1148] Exiting Socket#3881099::Receive() -> 73#73
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Send()
System.Net.Sockets Verbose: 0 : [1148] Data from Socket#3881099::Send
System.Net.Sockets Verbose: 0 : [1148] 00000000 : 45 48 4C 4F 20 62 6B 70-30 31 0D 0A : EHLO bkp01..
System.Net.Sockets Verbose: 0 : [1148] Exiting Socket#3881099::Send() -> 12#12
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Receive()
System.Net.Sockets Verbose: 0 : [1148] Data from Socket#3881099::Receive
System.Net.Sockets Verbose: 0 : [1148] 00000000 : 32 35 30 2D 62 67 6D 70-6F 6D 72 32 2E 73 61 73 : 250-bgmpomr2.sas
System.Net.Sockets Verbose: 0 : [1148] 00000010 : 6B 6E 65 74 2E 73 6B 2E-63 61 0D 0A 32 35 30 2D : knet.sk.ca..250-
System.Net.Sockets Verbose: 0 : [1148] 00000020 : 38 42 49 54 4D 49 4D 45-0D 0A 32 35 30 2D 50 49 : 8BITMIME..250-PI
System.Net.Sockets Verbose: 0 : [1148] 00000030 : 50 45 4C 49 4E 49 4E 47-0D 0A 32 35 30 2D 44 53 : PELINING..250-DS
System.Net.Sockets Verbose: 0 : [1148] 00000040 : 4E 0D 0A 32 35 30 2D 45-4E 48 41 4E 43 45 44 53 : N..250-ENHANCEDS
System.Net.Sockets Verbose: 0 : [1148] 00000050 : 54 41 54 55 53 43 4F 44-45 53 0D 0A 32 35 30 2D : TATUSCODES..250-
System.Net.Sockets Verbose: 0 : [1148] 00000060 : 48 45 4C 50 0D 0A 32 35-30 2D 58 4C 4F 4F 50 20 : HELP..250-XLOOP
System.Net.Sockets Verbose: 0 : [1148] 00000070 : 33 41 33 35 45 30 43 41-31 31 44 34 33 32 44 43 : 3A35E0CA11D432DC
System.Net.Sockets Verbose: 0 : [1148] 00000080 : 30 30 30 38 39 46 30 46-43 31 31 43 30 30 35 39 : 00089F0FC11C0059
System.Net.Sockets Verbose: 0 : [1148] 00000090 : 0D 0A 32 35 30 2D 53 54-41 52 54 54 4C 53 0D 0A : ..250-STARTTLS..
System.Net.Sockets Verbose: 0 : [1148] 000000A0 : 32 35 30 2D 41 55 54 48-20 50 4C 41 49 4E 20 4C : 250-AUTH PLAIN L
System.Net.Sockets Verbose: 0 : [1148] 000000B0 : 4F 47 49 4E 0D 0A 32 35-30 2D 41 55 54 48 3D 4C : OGIN..250-AUTH=L
System.Net.Sockets Verbose: 0 : [1148] 000000C0 : 4F 47 49 4E 0D 0A 32 35-30 2D 45 54 52 4E 0D 0A : OGIN..250-ETRN..
System.Net.Sockets Verbose: 0 : [1148] 000000D0 : 32 35 30 20 53 49 5A 45-20 30 0D 0A : 250 SIZE 0..
System.Net.Sockets Verbose: 0 : [1148] Exiting Socket#3881099::Receive() -> 220#220
System.Net Verbose: 0 : [1148] SmtpLoginAuthenticationModule#59346840::Authenticate()
System.Net Verbose: 0 : [1148] Exiting SmtpLoginAuthenticationModule#59346840::Authenticate()
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Send()
System.Net.Sockets Verbose: 0 : [1148] Data from Socket#3881099::Send
System.Net.Sockets Verbose: 0 : [1148] 00000000 : 41 55 54 48 20 6C 6F 67-69 6E 20 63 32 6C 74 63 : AUTH login hgjd6
System.Net.Sockets Verbose: 0 : [1148] 00000010 : 44 41 77 4E 77 3D 3D 0D-0A : 2pnw3==..
System.Net.Sockets Verbose: 0 : [1148] Exiting Socket#3881099::Send() -> 25#25
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Receive()
System.Net.Sockets Verbose: 0 : [1148] Data from Socket#3881099::Receive
System.Net.Sockets Verbose: 0 : [1148] 00000000 : 35 30 31 20 35 2E 35 2E-30 20 49 6E 76 61 6C 69 : 501 5.5.0 Invali
System.Net.Sockets Verbose: 0 : [1148] 00000010 : 64 20 69 6E 70 75 74 20-28 49 6E 76 61 6C 69 64 : d input (Invalid
System.Net.Sockets Verbose: 0 : [1148] 00000020 : 20 61 75 74 68 65 6E 74-69 63 61 74 69 6F 6E 20 : authentication
System.Net.Sockets Verbose: 0 : [1148] 00000030 : 70 72 6F 74 6F 63 6F 6C-29 2E 0D 0A : protocol)...
System.Net.Sockets Verbose: 0 : [1148] Exiting Socket#3881099::Receive() -> 60#60
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Send()
System.Net.Sockets Verbose: 0 : [1148] Data from Socket#3881099::Send
System.Net.Sockets Verbose: 0 : [1148] 00000000 : 4D 41 49 4C 20 46 52 4F-4D 3A 3C 6D 69 6B 65 2E : MAIL FROM:<mike.
System.Net.Sockets Verbose: 0 : [1148] 00000010 : 6C 61 76 65 6E 64 65 72-40 73 69 6D 70 6C 79 6F : lavender@simplyo
System.Net.Sockets Verbose: 0 : [1148] 00000020 : 66 66 73 69 74 65 2E 63-6F 6D 3E 0D 0A : ffsite.com>..
System.Net.Sockets Verbose: 0 : [1148] Exiting Socket#3881099::Send() -> 45#45
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Receive()
System.Net.Sockets Verbose: 0 : [1148] Data from Socket#3881099::Receive
System.Net.Sockets Verbose: 0 : [1148] 00000000 : 35 33 30 20 35 2E 37 2E-30 20 4E 6F 20 41 55 54 : 530 5.7.0 No AUT
System.Net.Sockets Verbose: 0 : [1148] 00000010 : 48 20 63 6F 6D 6D 61 6E-64 20 68 61 73 20 62 65 : H command has be
System.Net.Sockets Verbose: 0 : [1148] 00000020 : 65 6E 20 67 69 76 65 6E-2E 0D 0A : en given...
System.Net.Sockets Verbose: 0 : [1148] Exiting Socket#3881099::Receive() -> 43#43
System.Net Error: 0 : [1148] Exception in the SmtpClient#39722444::Send - The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 No AUTH command has been given.
System.Net Error: 0 : [1148] at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
System.Net.Sockets Verbose: 0 : [1148] Socket#3881099::Dispose()
System.Net Verbose: 0 : [1148] Exiting SmtpClient#39722444::Send()
So the normal SMTP commands should look something like this. Red are my entries Black are the servers response:
ehlo localhost
250-bgmpomr2.sasknet.sk.ca
250-8BITMIME
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-HELP
250-XLOOP 3A35E0CA11D432DC00089F0FC11C0059
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=LOGIN
250-ETRN
250 SIZE 0
auth login
334 VXNlcm5hbWU6
p3ltcAKw89==
334 UGFzc3dvcmQ6
ZcM67Bhyl4==
235 2.7.0 login authentication successful.
Microsoft does things this way
ehlo localhost
250-bgmpomr2.sasknet.sk.ca
250-8BITMIME
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-HELP
250-XLOOP 3A35E0CA11D432DC00089F0FC11C0059
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=LOGIN
250-ETRN
250 SIZE 0
auth login p3ltcAKw89==
501 5.5.0 Invalid input (Invalid authentication protocol)
You can test the problem with your SMTP server by telneting to it.
i.e. telnet yourmailserver.com 25
i hope this helps someone, or at least keeps them from wasting 2 days trying to figure out what the problem is. It also appears to be a problem with the IIS smtp services as well (2000 & 2003 server).
Now all I need is a solution
Mike Lavender
www.simplyoffsite.com Data backup for everyone.
What have you got to lose?