2013-02-12 41 views
10

我正在使用以下和平的代碼發送郵件使用godaddy託管。System.Net.Mail.SmtpException:操作已超時。在asp.net中的錯誤使用godaddy託管發送郵件代碼

但其拋System.Net.Mail.SmtpException: The operation has timed out.

protected void sendmail() 
    { 
     var fromAddress = "[email protected]"; 
     // any address where the email will be sending 
     var toAddress = "[email protected]"; 
     //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: [email protected]"; 
     // smtp settings 
     var smtp = new System.Net.Mail.SmtpClient(); 
     { 
      //smtp.Host = "relay-hosting.secureserver.net"; 
      smtp.Host = "smtpout.secureserver.net"; 
      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); 
    } 
+0

我相信使用SSL SMTP端口應爲465 – fofik 2013-02-12 08:34:37

+0

讓我查一下,這也..thanks您的時間。 – rahularyansharma 2013-02-12 08:40:03

+0

仍然是同樣的錯誤:( – rahularyansharma 2013-02-12 08:42:10

回答

-4

只是改變:

smtp.Timeout = 20000;

smtp.Timeout = 2000000;

+0

大聲笑這是一個殺手超時!? – 2014-04-22 14:34:20

+14

大聲笑。「client.Timeout = int.MaxValue;」怎麼樣? – Rikki 2014-10-15 00:39:57

相關問題