System.Net.Mail.SmtpException: The operation has timed out. error in send mail code using godaddy hosting

I am using following peace of code to send mail using godaddy hosting .

but its throw System.Net.Mail.SmtpException: The operation has timed out.

protected void sendmail()
        var fromAddress = "<a href="" class="__cf_email__" data-cfemail="cfa9bda0a2a2aea6a3a6ab8fbca6bbaae1aca0a2">[email protected]</a>";
        // any address where the email will be sending
        var toAddress = "<a href="" class="__cf_email__" data-cfemail="0a7e654a6d676b636624696567">[email protected]</a>";
        //Password of your gmail address
        const string fromPassword = "mypassword";
        // Passing the values and make a email formate to display
        string subject = "HI test mail ";
        string body = "From: <a href="" class="__cf_email__" data-cfemail="86f6f4e9c6e3abeee9f2e3eaf5f6f4e9a8e5e9eb">[email protected]</a>";
        // smtp settings
        var smtp = new System.Net.Mail.SmtpClient();
            //smtp.Host = "";
            smtp.Host = "";
            smtp.Port = 80;
            smtp.EnableSsl = true;
            smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
            smtp.Timeout = 20000;
        // Passing values to smtp object
        smtp.Send(fromAddress, toAddress, subject, body);


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I think this is the famous SSL issue of System.Net.Mail

System.Net.Mail with SSL to authenticate against port 465

You should use some external library or wait until Microsoft include this features in a framework release

Method 2

Just Change:

smtp.Timeout = 20000;


smtp.Timeout = 2000000;

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x