We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SmptClient - Authenticate via NTLM is not working and some questions

Hi,

I have an issue with our SmtpClient. Our Smtp-Server requires authentication and I tried it with SecurityMode automatic but via WireShark I saw that not AUTH comamnd is send.

So I tried to set it so NTLM but it seems to have no effect. Perhaps I misunderstood something.
Here is the code I am using. I used a alias for Aspose to prevent a conflict with the .NET SmtpClient

var client = new AsposeSmtpClient(Host) {
EnableSsl = EnableSsl,
Password = Password,
Port = Port,
Username = Username,
};
ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidationHandler;
client.SecurityMode = SmtpSslSecurityMode.Explicit;
client.AuthenticationMethod = SmtpAuthentication.Ntlm;
var message = new AsposeMailMessage() {
From = new MailAddress(mailMessage.From)
};
message.To.Add(mailMessage.To);
message.Subject = mailMessage.Subject;
message.TextBody = mailMessage.TextBody;
try {
client.Send(message);
} catch (AsposeSmtpException e) {
throw new SmtpException(“Error”, e);
}
}

Before I forget, could you tell me what is the difference between the 2 SmtpSslSecurityMode value? When to use what?

And another point is, our SSL Ceritificate is invalid. Is ther e some way to ignore this? I tried it with the event ServerCertificateValidationCallback (found it in the forum related to imap) but it doesn’t work.

Regards,
Torsten

Hi Torsten,


Thank you for inquiry.

Could you please try the example at http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/accessing-gmail-on-ssl.html to connect to your SMTP server and see if it works? You may leave the SmtpClient.AuthenticationMethod to default, if it does not work.

For SSL based SMTP connection, we prefer and recommend Explicit mode. Implicit for IMAP and POP.

Regarding invalid certificate, the above mentioned method should work. Could you please try again with Explicit security mode of SMTP?

Hi saqib,

your example is working fine. Using SSL is working. It is not working if do not use SSL however when I use the .NET smtp client it is working without SSL.

I have compared the smtp commands wich are sent by your smtp client with the built in from .NET 2.0 and what I can see is that .NET smtp client uses AUTH NTLM to login where aspose smtp client is not calling AUTH and I get a not authorized error.

Even if I explicitly say aspose smtp shall use ntlm it is not using it.
So whats the problem here? And thats the problem I tried to explain in my initial post. Sorry if it was a little bit unclear.

Best regards,
Torsten

P.S. The SSL certificate error occurs no matter what I set up. The errors root is a wrong dns name in the certificate. If I change the servername to the correct one it is working without the error so thats not the problem. However I have not found a way to ignore this error.