title: Anybody knows how to send SSL emails with System.Net.Mail through GoDaddy email servers
body: <p>I researched this on SO and could not find a truly complete answer.
  Many people, including myself, are able to send an email through C# System.Net.Mail by using port 25 or 587 and NOT using SSL. For example, see here:
  <a href="https://stackoverflow.com/questions/1317809/sending-email-using-a-godaddy-account">https://stackoverflow.com/questions/1317809/sending-email-using-a-godaddy-account</a></p>
  
  <p>Others have a solution using System.Web.Mail which is obsolete though:
  <a href="https://stackoverflow.com/questions/1011245/how-can-i-send-emails-through-ssl-smtp-with-the-net-framework">How can I send emails through SSL SMTP with the .NET Framework?</a></p>
  
  <p>However, it seems nobody has a solution yet on how to send the emails using SSL with port 465. Does anybody have a solution or at least knows why SSL is not working from C#?</p>
  
  <p>Here is the code I'm using:</p>
  
  <pre><code>try
  {
      MailMessage mail = new MailMessage("sender@yourdomain.com", receivingEmail, subject, body);
      string host = "smtpout.secureserver.net";
      int port = 465; // it's 465 if using SSL, otherwise 25 or 587
      SmtpClient smtpServer = new SmtpClient(host, port);
      smtpServer.Credentials = new NetworkCredential("sender@yourdomain.com", "yourpassword");
      smtpServer.EnableSsl = true;
      smtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
      smtpServer.Send(mail);
  }
  catch (Exception ex)
  {
      // do something with the exception
      ...
  }
  </code></pre>