2013-02-12 35 views
10

Tôi đang sử dụng mã an toàn sau để gửi thư bằng cách sử dụng lưu trữ Godaddy.System.Net.Mail.SmtpException: Thao tác đã hết thời gian chờ. lỗi trong asp.net gửi mail code bằng cách sử dụng godaddy hosting

nhưng ném nó 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

Tôi tin cảng smtp với ssl nên 465 – fofik

+0

hãy để tôi kiểm tra này cũng ..thanks cho thời gian của bạn. – rahularyansharma

+0

vẫn lỗi tương tự: ( – rahularyansharma

Trả lời

-4

Chỉ cần thay đổi:

smtp.Timeout = 20000;

Để

smtp.Timeout = 2000000;

+0

lol Đây là thời gian chờ của kẻ giết người? –

+14

LOL .. Làm thế nào về "client.Timeout = int.MaxValue;"? – Rikki