title: send email C# using smtp server with username password authentification
body: <p>I have a piece of code that sends email.. heres the code</p>
  
  <p>This is not working for me. This a remote smtp service ... and i double checked that email web access works fine .. i can login using the gui, recieve and send emails.</p>
  
  <p>But when i try to do it through code .. it fails with the message ...</p>
  
  <blockquote>
    <p>{System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 No AUTH command has been given.</p>
  </blockquote>
  
  <p>Can anybody advise ... and also they dont have EWS exposed ie.e exchange web service ./.. this is the way to go .. </p>
  
  <p>port is 25 and no SSL or TLS</p>
  
  <pre><code>Button b = sender as Button;
  try
  {
      MailMessage msg = new MailMessage(senderEmail, recieverEmail, "afdasfas", "safasfa");
      //MailMessage msg = new MailMessage(senderEmail, recieverEmail, subject, subject);
      System.Net.Mail.SmtpClient mailclient = new System.Net.Mail.SmtpClient(EmailSmtpServer, outgoingPort);
      System.Net.NetworkCredential auth = new System.Net.NetworkCredential(senderEmail, senderPassword);
      mailclient.Host = EmailSmtpServer;
      mailclient.UseDefaultCredentials = false;
      mailclient.Credentials = auth;
      mailclient.Send(msg);
      MessageBox.Show(b.Content + ":WORKED");
  }
  catch (Exception e4)
  {
      MessageBox.Show(b.Content + ": " +e4.Message);
      MessageBox.Show(b.Content + ": " + e4.StackTrace);
  }
  </code></pre>