Trouble Sending SMTP Email from GoDaddy Hosted ASP.NET Web Forms Application

81898447 0 Reputation points
2023-10-19T13:31:09.42+00:00
I am encountering an issue while trying to send emails through an ASP.NET Web Forms application hosted on GoDaddy's server. The goal is to send emails from a Gmail address using C# and the SmtpClient.

using (MailMessage mm = new MailMessage("******@gmail.com", "******@gmail.com"))
{
                mm.Subject = "test";
                mm.Body = "test";
                mm.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "relay-hosting.secureserver.net";
                smtp.EnableSsl = true;
                smtp.Port = 25;
                NetworkCredential NetworkCred = new NetworkCredential("******@gmail.com", "XXXXXX");
                smtp.UseDefaultCredentials = true;
                smtp.Credentials = NetworkCred;
                smtp.Send(mm);
}
Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. DotNetCrazy 0 Reputation points
    2023-10-20T03:12:33.1066667+00:00

    Hi,

    Is there any error message that you see? Please make sure you contact your hosting provider and ask them about correct settings that you need to use.

    0 comments No comments

  2. QiYou-MSFT 4,326 Reputation points Microsoft External Staff
    2023-10-20T09:29:39.6766667+00:00

    Hi @81898447

    Google Mail's host should be "smtp.gmail.com" and the port is 587.

    Change code:

    smtp.Host = "smtp.gmail.com";
    smtp.Port = 587;
    
    
    

    Best regards,
    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.