Authentication unsuccessfull (535) SmtpException while using Rebex.Net.Smtp

0 votes
asked Feb 19, 2013 by velin_achev (280 points)
edited Feb 20, 2013

Hello, I get the following error while trying to authenticate against a smtp mail server: "Authentication unsuccessful (535).".

It's interesting that I can log in to this server and even send a mail when using .net object System.Net.Mail.SmtpClient (using the same credentials).

So, the following code works:

using (SmtpClient client = new SmtpClient("{server_name_or_address}", 25))
                {
                    client.Credentials = new System.Net.NetworkCredential("{username}", "{password}");
                    client.Send("{from}", "{to}", "TEST", "TEST");
                }

However, when using Rebex library - the aforementioned exception occurs on login line:

Smtp smtp = new Smtp();
smtp.Connect("{server_name_or_address}", 25, null, SmtpSecurity.Unsecure);
smtp.Login("{username}", {password});

The server does not allow explicit ssl connection, actually I've tried different configurations playing with SmtpAuthentication and SmptSecurity parameters.

My question is - why I can log in using the .net classes and how can I provide the same configuration as .net library do? Or, is there a way do debug and get infomation about passed parameters and credentials?

Regards, Velin Achev

Applies to: Rebex Secure Mail
commented Feb 19, 2013 by Lukas Matyska (55,430 points)
edited Feb 20, 2013

Can you please try to send the mail without logging in (actually, system SmtpClient tries it):

using (Smtp smtp = new Smtp())
{
    smtp.Connect("{server_name_or_address}", 25);
    //smtp.Login("{username}", "{password}");
    smtp.Send("{from}", "{to}", "TEST", "TEST");
    smtp.Disconnect();
}

2 Answers

0 votes
answered Feb 20, 2013 by velin_achev (280 points)
edited Feb 20, 2013

Lukas,

yes, I can send an email without loging in (i.e anonymous authentication).

Also, in the debugging process I created event handlers for the smtp object's events - ResponseRead and CommandSent. I was able to read the commands sent from mail server and client. The communication is base64 encoded. When asked for username, the client supplied username encoded (that read through event args Command property). But, was not able to read the password - it appeared as string of whitespaces - is it ok?

Regards, Velin

commented Feb 20, 2013 by Lukas Matyska (55,430 points)
edited Feb 20, 2013

Yes, it is correct. Password is replaced by whitespaces for security reason.

However, if you want to easily check what is sent to the server, you can use LogWriter property and use LogLevel.Verbose. In Verbose level all bytes transmitted between client and server are logged. You can use it like this:

smtp.LogWriter = new Rebex.FileLogWriter("D:/smtp.log", LogLevel.Verbose);
commented Feb 20, 2013 by Lukas Matyska (55,430 points)
edited Feb 20, 2013

Can you please try following with the system SmtpClient:

  1. use invalid password in client.Credentials
  2. don't use client.Credentials at all

Are you still able to send a mail using your SMTP server in both cases?

+1 vote
answered Feb 20, 2013 by velin_achev (280 points)
edited Feb 20, 2013

Thank you Lukas for the examples and suggestions. It appears that both supplying invalid credentials and not supplying them at all works - anonymous connections are allowed to the mail server.

It turns out that the credentials I have are invalid and Rebex does not do an implicit anonymous request like SmtpClient does. I'll write back at this thread again when I confirm the right credentials. Yet, its good to see the interesting behavior this system SmtpClient have..

Regards,

Velin

...