title: Permission issues when trying to send email via SMTP from ASP.NET page
body: <p>I have done this before without any issue but now I don't know what's wrong. I have a web page with a button for email which I want to send some data to email addresses with.</p>
  
  <p>I asked our web hosting company for server details and the response I got was:</p>
  
  <pre><code>"You can use the following details for mail.
  
  Incoming mail server: mail.ourSite.com Outgoing mail server: mail.ourSite.com
  
  Username and password are the email address and password associated with the email address.
  "
  </code></pre>
  
  <p>I am not sure about the last line but I created a new email address in the web host's control panel.</p>
  
  <p>The code I use is:</p>
  
  <pre><code>// instantiate a new mail definition and load an html
  // template into a string which I replace values in
  // then the rest of the code below
  md.Subject = String.Format("{0} {1} {2}", emailSubject, firstName, lastName);
  
  MailMessage msg = md.CreateMailMessage(emailAddress, replacements, emailBody, new Control());
  md.IsBodyHtml = true;
  SmtpClient sc = new SmtpClient(emailServer);            
  sc.Credentials = new NetworkCredential(emailUsername, emailPassword);
      try
      {
          sc.Send(msg);
      }
  </code></pre>
  
  <p>emailServer - mail.ourSite.com (dummy value in this post)
  emailUsername - the email address I created in the control panel
  emailPassword - the password for the email above</p>
  
  <p>The error I have is that when I send emails to other domains than our own I get </p>
  
  <pre><code>"Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server."
  </code></pre>
  
  <p>When I email to an address within our host then it works fine.</p>
  
  <p>The support is not very supportive so I am asking here what you might think the problem could be? I find it strange that I use the password for an email address I created, should it really be like that?</p>