title: Mailkit authenticating self hosted email with my exchange server?
body: <p>Essentially, I have a local mail server with exchange and active directory and etc.. I'm trying to authenticate an email with Mailkit in C# but I get an authentication error every single time. I've tried many different ways of using client#Authenticate by using &quot;int\name&quot;, &quot;password&quot;  or &quot;name&quot;, &quot;password&quot;  or &quot;address&quot;, &quot;password&quot; etc. Here's my code:</p>
  <pre><code>public Email()
      {
  
          var message = new MimeMessage();
          message.From.Add(new MailboxAddress(&quot;&quot;, &quot;my@emailaddress.com&quot;));
          message.To.Add(new MailboxAddress(&quot;&quot;, &quot;toemail@gmail.com&quot;));
          message.Subject = &quot;test email&quot;;
  
          message.Body = new TextPart(&quot;plain&quot;)
          {
              Text = @&quot;test&quot;
          };
  
          var client = new SmtpClient();
          client.Connect(&quot;my.mailserver.com&quot;, 25, MailKit.Security.SecureSocketOptions.StartTls);
          client.Authenticate(&quot;my@emailaddress.com&quot;, &quot;mypassword&quot;);
          client.Send(message);
  
          client.Disconnect(true);
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/LPt6g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LPt6g.png" alt="enter image description here" /></a></p>