+1 vote

We are trying to send an Email using Limilab SMTP class and we are getting this Error:

504 5.7.4 Unrecognized authentication type

The Code we are using is the following:

Smtp smtpClient = new Smtp();

        MailBuilder builder = new MailBuilder();
        builder.From.Add(new MailBox("support@something.com"));
        builder.To.Add(new MailBox("notifications@something.com"));
        builder.Subject = "Test";
        builder.Text = "";
        IMail email = builder.Create();

        smtpClient.Connect("mail.something.com");
        bool supportsTLS = smtpClient.SupportedExtensions()
              .Contains(SmtpExtension.StartTLS);
        if (supportsTLS)
        {
            smtpClient.StartTLS();
        }
        smtpClient.UseBestLogin("support", "something");
        ISendMessageResult result = smtpClient.SendMessage(email);

This is the Logs from the Logging File:

Mail.dll Information: 0 : 1 09:19:53 3.0.18026.1647
Mail.dll Information: 0 : 1 09:19:53 Checking if license file is present.
Mail.dll Information: 0 : 1 09:19:53 Connecting to 'mail.something.com:587', SSL: False.
Mail.dll Information: 0 : 1 09:19:53 S: 220 someting.something.local Microsoft ESMTP MAIL Service ready at Thu, 8 Mar 2018 09:19:52 -0500
Mail.dll Information: 0 : 1 09:19:53 C: EHLO [66.24.149.99]
Mail.dll Information: 0 : 1 09:19:53 S: 250-someting.something.local Hello [66.54.154.111]
Mail.dll Information: 0 : 1 09:19:53 S: 250-SIZE 36700160
Mail.dll Information: 0 : 1 09:19:53 S: 250-PIPELINING
Mail.dll Information: 0 : 1 09:19:53 S: 250-DSN
Mail.dll Information: 0 : 1 09:19:53 S: 250-ENHANCEDSTATUSCODES
Mail.dll Information: 0 : 1 09:19:53 S: 250-STARTTLS
Mail.dll Information: 0 : 1 09:19:53 S: 250-8BITMIME
Mail.dll Information: 0 : 1 09:19:53 S: 250-BINARYMIME
Mail.dll Information: 0 : 1 09:19:53 S: 250 CHUNKING
Mail.dll Information: 0 : 1 09:19:53 C: STARTTLS
Mail.dll Information: 0 : 1 09:19:53 S: 220 2.0.0 SMTP server ready
Mail.dll Information: 0 : 1 09:19:53 C: EHLO [66.24.149.99]
Mail.dll Information: 0 : 1 09:19:53 S: 250-someting.something.local Hello [66.54.154.111]
Mail.dll Information: 0 : 1 09:19:53 S: 250-SIZE 36700160
Mail.dll Information: 0 : 1 09:19:53 S: 250-PIPELINING
Mail.dll Information: 0 : 1 09:19:53 S: 250-DSN
Mail.dll Information: 0 : 1 09:19:53 S: 250-ENHANCEDSTATUSCODES
Mail.dll Information: 0 : 1 09:19:53 S: 250-8BITMIME
Mail.dll Information: 0 : 1 09:19:53 S: 250-BINARYMIME
Mail.dll Information: 0 : 1 09:19:53 S: 250 CHUNKING
Mail.dll Information: 0 : 1 09:19:53 C: AUTH LOGIN
Mail.dll Information: 0 : 1 09:19:53 S: 504 5.7.4 Unrecognized authentication type

by

1 Answer

0 votes

Does your server require authentication?

Please try removing UseBestLogin line.

by (286k points)
edited by
Thank you for your Reply. So you are saying we do not Log in? Just Connect and try to Send?
Your server doesn't return any authentication methods and doesn't recognize most basic one. My assumption is no authentication is required.
Is there a way in Limilab to check if Authentication is required?
You may use SupportedAuthenticationMethods, however some servers require authentication, but don't send any AUTH responses. I would say it's better to try using UseBestLogin even if no authentication methods are returned.
Can I do this?

            try
            {
                smtpClient.UseBestLogin("support", "something");
            }
            catch (Exception ex)
            {
                if (!ex.Message.Contains("Unrecognized authentication type"))
                    throw;
            }

            ISendMessageResult result = smtpClient.SendMessage(email);



In other words, Can I rely on "Unrecognized authentication type" in the Exception message to ignore it? Knowing that, I still need to catch if Authentication is failing because of wrong username or password in case Authentication is required.

I appreciate your fast reply to my question. IT is very critical.
This error message is returned by the server. I would not rely on it.
So what do you suggest here we always try to do Log in

            try
            {
                smtpClient.UseBestLogin("support", "something");
            }
            catch (Exception ex)
            {
                
            }
            ISendMessageResult result = smtpClient.SendMessage(email);
I'm suggesting to display the error message to the user, and add 'no authentication required' option as a user setting.
...