Sending email with smtp.secureserver.net with C# and GoDaddy
10,362
GOT IT!!! Need to remove the line "client.EnableSsl = true;" because godaddy does not accept secure connections.
Author by
Rob
Updated on June 04, 2022Comments
-
Rob almost 2 years
this is driving me absolutely crazy. I am trying to send an email through a web service written in C# through GoDaddy's servers (smtp.secureserver.net) but for some reason it's not working. Here's my code:
public static void SendMessage(string mailFrom, string mailFromDisplayName, string[] mailTo, string[] mailCc, string subject, string body) { try { using (SmtpClient client = new SmtpClient("smtpout.secureserver.net")) { client.Credentials = new NetworkCredential("[email protected]", "mypassword"); client.EnableSsl = true; //client.Credentials = CredentialCache.DefaultNetworkCredentials; //client.DeliveryMethod = SmtpDeliveryMethod.Network; string to = mailTo != null ? string.Join(",", mailTo) : null; string cc = mailCc != null ? string.Join(",", mailCc) : null; MailMessage mail = new MailMessage(); mail.From = new MailAddress(mailFrom, mailFromDisplayName); mail.To.Add(to); if (cc != null) { mail.CC.Add(cc); } mail.Subject = subject; mail.Body = body.Replace(Environment.NewLine, "<BR>"); mail.IsBodyHtml = true; client.Send(mail); } } catch (Exception ex) { // exception handling } } string[] mailTo = { "[email protected]" }; SendMessage("[email protected]", "Test Email", mailTo, null, "Secure Server Test", "Testing... Sent at: " + DateTime.Now);
-
Rob over 12 yearsYes there was! I just realized I wasn't even checking the catch loop. Thank you!!
-
-
Sinjai over 5 years7 years later, this was my issue as well. Was trying to use SSL on 465, which GoDaddy's website claims is a thing, but apparently I have to use plaintext on 25...