2016-08-22 57 views
0

我有聯繫formin我的網站。有窗口與GoDaddy託管。當我在我的本地主機上測試聯繫人時,它的工作原理是&發送郵件,但在託管它時會出現異常。郵件不發送從虛擬主機服務器

System.Net.Mail.SmtpException:發送郵件失敗。 ---> System.Net.WebException:無法連接到遠程服務器---> System.Net.Sockets.SocketException:試圖以訪問權限74.125.130.108:587禁止的方式訪問套接字在System.Net.ServicePoint.ConnectSocketInternal(布爾connectFailure,套接字s4,套接字s6,套接字&套接字,IP地址&地址,ConnectSocketState狀態,IAsyncResult asyncResult,異常結果在System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,SocketAddress套接字地址) &例外)---在System.Net上的System.Net.ServicePoint.GetConnection(PooledStream PooledStream,Object owner,Boolean async,IPAddress & address,Socket & abortSocket,Socket & abortSocket6)處結束內部異常堆棧跟蹤。 PooledStream.Activate(Object owningObject,Boolean async,GeneralAsyncDelegate System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)at System.Net.ConnectionPool.GetConnection(Object owningObject,GeneralAsyncDelegate asyncCallback,Int32 creationTimeout)在System.Net.PooledStream.Activate(Object owningObject,GeneralAsyncDelegate asyncCallback)上的asyncCallback) System.Net.Mail.System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)System.Net.Mail.SmtpClient.GetConnection()System.Net.Mail.SmtpClient.Send(MailMessage消息)---內部異常堆棧跟蹤結束 - - 位於G:\ PleskVhosts \ brandstik.in \ httpdocs \ DynamicPage.aspx.vb中的DynamicPage.sendInquiry_Click(Object sender,EventArgs e)處的System.Net.Mail.SmtpClient.Send(MailMessage消息):第173行

try { 
    MailMessage mail = new MailMessage(); 
    SmtpClient SmtpServer = new SmtpClient(); 
    mail.To.Add("[email protected]"); 
    mail.From = new MailAddress(inquiryEmail.Text); 
    mail.Subject = "Quote Request For " + quoteID.Text; 
    mail.Body = "New Quote request from customer<br /><br/>Customer Name - '" + inquiryName.Text + "' <br />Customer Email - '" + inquiryEmail.Text + "'<br />Customer Contact - '" + inquiryNumber.Text + "'<br />Comment - '" + inquiryMessage.Text + "'"; 
    mail.IsBodyHtml = true; 
    SmtpServer.Port = 587; 
    SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "1234567890"); 
    SmtpServer.Host = "smtp.gmail.com"; 
    SmtpServer.EnableSsl = true; 
    SmtpServer.Send(mail); 
    Response.Write("Sent"); 
} catch (Exception ex) { 
    //Response.Write("<script language='javascript'>alert('Your SMTP Server needs to get configured to contact form work.');</script>") 
    Response.Write(ex); 
} 
+0

聯繫GoDaddy支持並驗證應用程序未被阻止! –

+0

請參考:[Gmail SMTP不再在Godaddy服務器上工作](http://forums.asp.net/t/2094021.aspx?Gmail+SMTP+no+longer+working+in+Godaddy+Server) –

+0

您可能需要使用HTTP而不是SMTP訪問您的Gmail,以避開GoDaddy的限制。考慮Gmail API:https://developers.google.com/gmail/api/guides/ – Michael

回答

0

似乎他們不允許它。您需要使用GoDaddys電子郵件中繼服務器。請參閱手冊:https://www.godaddy.com/help/send-email-using-systemnetmail-19291

+0

SmtpServer.Host =「smtp.gmail.com」您的意思是GoDaddy不允許這麼做? – SUN

+0

對,你必須使用relay-hosting.secureserver.net那裏 – at0mzk

+0

你確定嗎?我必須使用gmail發送電子郵件,然後我需要使用relay-hosting.secureserver.net? – SUN

相關問題