SMTPClient do not send authorisation properly  
Author Message
ChanKaiShi1





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

Hi,

I have very simple code which tries to send email via relay server requiring authorisation. Code is below. It does not work becouse after running sniffer I found .NET runtiime is incorrectly sending AUTH field to server

142.165.72.18     192.168.251.102    Response: 220 bgmpomr2.sasknet..ca -- Server ESMTP (SaskTel eMessaging Service)
192.168.251.102    142.165.72.18     Command: EHLO workhome
142.165.72.18     192.168.251.102    Response: 250-bgmpomr2.sasknet.sk.ca
192.168.251.102    142.165.72.18     Command: AUTH login ZmFz
142.165.72.18     192.168.251.102    Response: 501 5.5.0 Invalid input (Invalid authentication protocol).


 AUTH login is not supposed to be followed by anything but it's followed looks like by encoded username and password. This was supposed to be sent on next SMTP handshake.

Code is as follows

 

SmtpClient MyClient = new SmtpClient("smtp.some.com");
MyClient.DeliveryMethod = SmtpDeliveryMethod.Network;
MyClient.UseDefaultCredentials = false;
System.Net.NetworkCredential MyCredential = new System.Net.NetworkCredentialProperties.Settings.Default.MailServerUsername, Properties.Settings.Default.MailServerPassword);
MyClient.Credentials = MyCredential ;
, "asda", "asda")



.NET Development30  
 
 
Durgaprasad Gorti





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

I believe the RFC 2554 allows it

The authentication protocol exchange consists of a series of
server challenges and client answers that are specific to the
authentication mechanism. A server challenge, otherwise known
as a ready response, is a 334 reply with the text part
containing a BASE64 encoded string. The client answer consists
of a line containing a BASE64 encoded string. If the client
wishes to cancel an authentication exchange, it issues a line
with a single "*". If the server receives such an answer, it
MUST reject the AUTH command by sending a 501 reply.



 
 
ChanKaiShi1





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

Well I don't want to go digging inside RFC

I made a capture on Outlook Express and it does not do it. I had to abandon using .NET class for sending email and go to third party solution which worked fine out of the box.

I don't know if it's bug or not but it's definetely not working at least on server I tested with but Outlook Express, and ALL third party SMTP components (I tested 3) worked fine.


 
 
Malar Chinnusamy





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

Thanks for bringing this issue to our attention. We are looking into it now.

Can you send us the trace from Outlook express or the third party SMTP components.


 
 
ChanKaiShi1





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

I have it in Ethereal format but high level output is below (from OE with the same settings). I can send detailed output to email if needed.

No. Time Source Destination Protocol Info
1 0.000000 142.165.72.18 192.168.251.102 SMTP Response: 220 bgmpomr1.sasknet.sk.ca -- Server ESMTP (SaskTel eMessaging Service)
2 0.000125 192.168.251.102 142.165.72.18 SMTP Command: EHLO workhome
3 0.222016 142.165.72.18 192.168.251.102 SMTP Response: 250-bgmpomr1.sasknet.sk.ca
4 0.222998 192.168.251.102 142.165.72.18 SMTP Command: AUTH LOGIN
5 0.391516 142.165.72.18 192.168.251.102 SMTP Response: 334 VXNhbWU6
6 0.391674 192.168.251.102 142.165.72.18 SMTP Message Body
7 0.503792 142.165.72.18 192.168.251.102 SMTP Response: 334 UGFdvcmQ6
8 0.503976 192.168.251.102 142.165.72.18 SMTP Message Body
9 0.614157 142.165.72.18 192.168.251.102 SMTP Response: 235 2.7.0 LOGIN authentication successful.
>


 
 
oxAndy





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

Hi

We have he same Problem. Any solution yet

The Code works fine when sending mail direct to the Exchange 2003. If we send to a Product called XWALL (http://www.lakecomm.com/) it fails...

Our trace (Failed with .NET 2.0 SMTP):
(Note: i blanked out the base64 Username/PW Part with (***BLANKED_OUT_BASE64***))

06-10-11 14:13:06 0005: > 220 mail.ourserver.com ESMTP XWall v3.38

06-10-11 14:13:06 0005: < EHLO ourproxy

06-10-11 14:13:06 0005: > 250-mail.ourserver.com

06-10-11 14:13:06 0005: > 250-ENHANCEDSTATUSCODES

06-10-11 14:13:06 0005: > 250-ETRN

06-10-11 14:13:06 0005: > 250-DSN

06-10-11 14:13:06 0005: > 250-PIPELINING

06-10-11 14:13:06 0005: > 250-8BITMIME

06-10-11 14:13:06 0005: > 250-PRIORITY

06-10-11 14:13:06 0005: > 250-CHUNKING

06-10-11 14:13:06 0005: > 250-SIZE

06-10-11 14:13:06 0005: > 250-AUTH=LOGIN

06-10-11 14:13:06 0005: > 250-AUTH PLAIN LOGIN CRAM-MD5

06-10-11 14:13:06 0005: > 250-XBDATA

06-10-11 14:13:06 0005: > 250 XXWALL30

06-10-11 14:13:06 0005: < AUTH login b(***BLANKED_OUT_BASE64***)=

06-10-11 14:13:06 0005: > 334 V(***BLANKED_OUT_BASE64***)6

06-10-11 14:13:06 0005: < N(***BLANKED_OUT_BASE64***)=

06-10-11 14:13:06 0005: > 334 U(***BLANKED_OUT_BASE64***)6

06-10-11 14:13:06 0005: > 535 5.7.0 authentication of 77xJt$345sq failed, access denied

 

Correct Trace (BY 3th Part SMTP Client):

---------------------------------------------------------------

06-10-11 14:39:42 0008: < AUTH login

06-10-11 14:39:42 0008: > 334 V(***BLANKED_OUT_BASE64***)6

06-10-11 14:39:50 0008: < b(***BLANKED_OUT_BASE64***)==

06-10-11 14:39:50 0008: > 334 U(***BLANKED_OUT_BASE64***)6

06-10-11 14:39:58 0008: < N(***BLANKED_OUT_BASE64***)=

06-10-11 14:39:58 0008: > 235 2.7.0 user successfully authenticated

 

vb.net Code:

Public Sub Send()

Dim vMail As New MailMessage

Try

btnSend.Enabled = False

txtOut.Text = "Sending mail..." & vbCrLf

System.Windows.Forms.Application.DoEvents()

If chkPlaintext.Checked Then

vMail.IsBodyHtml = False 'Text

Else

vMail.IsBodyHtml = True 'html

End If

If Len(txtEncoding.Text) > 0 Then

Dim voE As System.Text.Encoding

voE = System.Text.Encoding.GetEncoding(txtEncoding.Text)

If voE Is Nothing Then

voE = System.Text.Encoding.Default

End If

vMail.BodyEncoding = voE

End If

If chkPlaintext.Checked Then

vMail.Body = txtBody.Text

Else

vMail.Body = gsFormatHTML_SMTP(txtBody.Text)

End If

vMail.Subject = txtSubject.Text

vMail.Priority = MailPriority.High

vMail.Sender = New MailAddress(txtSender.Text)

vMail.From = New MailAddress(txtSender.Text)

vMail.To.Add(txtTo.Text)

Err.Clear()

Dim voSMTP As New SmtpClient

voSMTP.Host = txtServer.Text

voSMTP.Port = txtPort.Text

voSMTP.Timeout = txtTimeout.Text * 1000

voSMTP.DeliveryMethod = SmtpDeliveryMethod.Network

If Len(txtAuthenticationUser.Text) > 0 Then

voSMTP.UseDefaultCredentials = False

Dim voC As New System.Net.NetworkCredential

voC.UserName = txtAuthenticationUser.Text

voC.Password = txtAuthenticationPW.Text

voC.Domain = txtDomain.Text

voSMTP.Credentials = voC

Else

voSMTP.UseDefaultCredentials = True

voSMTP.Credentials = System.Net.CredentialCache.DefaultCredentials()

End If

voSMTP.EnableSsl = chkEnableSSL.Checked

voSMTP.Send(vMail)

Catch ex As Exception

If TypeOf ex Is System.Net.Mail.SmtpException Then

Dim voE As SmtpException = ex

txtOut.Text = "!!!Couldn't send mail!!! (SmtpException)" & vbCrLf & "Error-Message: " & voE.Message & vbCrLf & "Server StatusCode: " & voE.StatusCode & vbCrLf & "Source: " & voE.Source & vbCrLf & vbCrLf & "StackTrace: " & vbCrLf & voE.StackTrace

ElseIf TypeOf ex Is System.Net.Mail.SmtpFailedRecipientException Then

Dim voE As SmtpFailedRecipientException = ex

txtOut.Text = "!!!Couldn't send mail!!! (FailedRecipient)" & vbCrLf & "Error-Message: " & voE.Message & vbCrLf & "Failed Recipients: " & voE.FailedRecipient & vbCrLf & "Source: " & voE.Source & vbCrLf & vbCrLf & "StackTrace: " & vbCrLf & voE.StackTrace

ElseIf TypeOf ex Is System.Net.Mail.SmtpFailedRecipientsException Then

Dim voE As SmtpFailedRecipientsException = ex

txtOut.Text = "!!!Couldn't send mail!!! (FailedRecipients)" & vbCrLf & "Error-Message: " & voE.Message & vbCrLf & "Failed Recipients: " & voE.FailedRecipient & vbCrLf & "Source: " & voE.Source & vbCrLf & vbCrLf & "StackTrace: " & vbCrLf & voE.StackTrace

Else

txtOut.Text = "!!!Couldn't send mail!!!" & vbCrLf & "Error-Message: " & ex.Message & vbCrLf & "Source: " & ex.Source & vbCrLf & vbCrLf & "StackTrace: " & vbCrLf & ex.StackTrace

End If

btnSend.Enabled = True

Exit Sub

End Try

txtOut.Text = "Mail sucessfully sent."

btnSend.Enabled = True

End Sub

Thanx

 


 
 
Mike Lavender





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

We are seeing the same problems with .net 2.0 System.Net. in (DotNetNuke) and the iis smtp services on both a windows 2000 and windows 2003 server.

Has anyone found a workaround for this I don't really feel like re-writing the code for mail in DotNetNuke.

Mike


 
 
Lorry Craig





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

I was original poster and there were no solution provided as I said before I had to use third party solution for that.
 
 
Mike Lavender





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

Thanks,

This post/thread helped me figure out what my problem was although a solution still waits. I ran into it trying to move our site over to DotNetNuke. I am having exactly the same problem with the IIS smtp services in Win 2000 and 2003 server as well.

Mike Lavender
Simply Offsite - What have you got to lose
Suite 208 - 416 21st Street East
Saskatoon, SK S7K 0C2
Canada
1.866.814.1110 - Toll Free
1.306.244.4880 - International


 
 
Kevin Williams





PostPosted: .NET Framework Networking and Communication, SMTPClient do not send authorisation properly Top

Hi

We have the same Problem. Any solution yet