title: Send email from webservice
body: <p>I have a method to send mails from c#:</p>
  
  <pre><code>public static void SendEmailWebService(string asunto, string body, string to)
  {
      try
      { // takes config from web.config
          MailMessage mm = new MailMessage
          {
              From = new MailAddress(@"no-reply@site.com", @"Notificacion"),
              To = { new MailAddress(to) },
              Subject = asunto,
              IsBodyHtml = true,
              Body = body,
              HeadersEncoding = System.Text.Encoding.UTF8,
              SubjectEncoding = System.Text.Encoding.UTF8,
              BodyEncoding = System.Text.Encoding.UTF8
          };
          Smtp.Send(mm);
      }
      catch (Exception ex)
      {
          // Error
      }
  }
  </code></pre>
  
  <p>If i call this method normaly, it works, but if i call it from a webservice then it fails.</p>
  
  <p>In the cathc, the exception is:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>I don't see why it's not worikng when I call it from the webservice.</p>