title: ASP.NET: Send Mail
body: <p>Im trying to send a mail from a asp.net script, but im getting this error:</p>
  
  <p><em>System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 4.1.8 : Sender address rejected: Domain not found at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException&amp; exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at Clematis_ADO.sites.Kvittering.Page_Load(Object sender, EventArgs e)</em></p>
  
  <p>As i understand this, it can't use the smtp server that i specified, but im using the smtp server giving by my webhost. So what could the error be?</p>
  
  <p>This is tested on the webhost, not localhost.</p>
  
  <p>And the code im using for this:</p>
  
  <pre><code> try
           {
               StringWriter sw = new StringWriter();
               HtmlTextWriter w = new HtmlTextWriter(sw);
               OrderConfirmationContainer.RenderControl(w);
               string s = sw.GetStringBuilder().ToString();
  
               MailMessage mail = new MailMessage();
  
               string emailSubject = "Testing";
  
               mail.To.Add(new MailAddress(order.getFname() + " " + order.getLname() + "&lt;"+order.getEmail()+"&gt;"));
               mail.Sender = new MailAddress("****** &lt;***@***.com&gt;");
               mail.From = new MailAddress("***@***.com");
               mail.Subject = emailSubject;
               mail.IsBodyHtml = true;
               mail.Body = "&lt;h3&gt;" + emailSubject + "&lt;/h3&gt;" + s;
  
               SmtpClient smtp = new SmtpClient();
               smtp.Host = "mailoutb1.surf-town.net";
               smtp.Send(mail);
  
           }
           catch (Exception exception)
           {
               if(exception != null)
                  MailLabel.Text = "Mail fejlen er: " + exception.ToString();
           }
  </code></pre>