2011-07-07 4 views
1

私はここ送信ボタンAsp.netウェブサイトのメールエラー

をクリックしたとき、私はシンプルな問い合わせフォーム...私に情報を送信作成した私はローカルで大丈夫コードを実行している問題ですサーバ。

Imports System.IO 
Imports System.Net.Mail 
Partial Class Contact_Form_Demo 
Inherits System.Web.UI.UserControl 

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 
    Dim fileName As String = Server.MapPath("~/App_Data/ContactForm.txt") 
    Dim mailBody As String = File.ReadAllText(fileName) 

    mailBody = mailBody.Replace("##Name##", TextBox1.Text) 
    mailBody = mailBody.Replace("##Email##", TextBox2.Text) 
    mailBody = mailBody.Replace("##HomePhone##", TextBox3.Text) 
    mailBody = mailBody.Replace("##BusinessPhone##", TextBox4.Text) 
    mailBody = mailBody.Replace("##Comments##", TextBox5.Text) 

    Dim mymessage As MailMessage = New MailMessage() 
    mymessage.Subject = "Response from web site" 
    mymessage.Body = mailBody 

    mymessage.From = New MailAddress("Email Here", "Tuhin Bhatt") 
    mymessage.To.Add(New MailAddress("My Email Here", "Tuhin Bhatt")) 

    Dim mysmtpclient As SmtpClient = New SmtpClient() 
    mysmtpclient.Send(mymessage) 
End Sub 
End Class 

は、これは私がライブサーバー上で取得エラーです:

 
Server Error in '/' Application. 
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.95.109:25 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.95.109:25 
Source Error: 
Line 26: 
Line 27:   Dim mysmtpclient As SmtpClient = New SmtpClient() 
Line 28:   mysmtpclient.Send(mymessage) 
Line 29:  End Sub 
Line 30: End Class 
+0

あなたのsmtpクライアントの詳細は何ですか? – gandil

答えて

3

しかし、それはコードです。ここ例外

を与えるライブサーバー(GoDaddyのサーバ)上 を実行しません。ホストされている環境では、Web.configで指定された設定でSMTPサーバーにアクセスすることはできません。 web.configファイルに<mailSettings>セクションがない場合は、アプリケーションがGoDaddyのmachine.configファイルで指定された設定にアクセスしようとしていることを意味します。そして、おそらく、その特定のサーバーとポートへのアクセスは許可されていない可能性があります。

ここでMailSettingsセクションを設定する方法をご覧ください。また、管理しているWebサイトのSMTPサーバーへの名前とパスワードを使用します。

+0

私はすでにWeb.configにセクションを設定しています。私もsmtpサーバ名をgoogleと指定しています...また、私のユーザ名とパスワードとenablessl属性をTrueに設定しました。それはGodaddyが私を制限しているからです。私は彼らの電子メールサーバーを使用する必要があります.... ????? –

2
Dim mysmtpclient As SmtpClient = New SmtpClient() 

プライバシー上の理由から除外しない限り、SmtpClinet()にはいくつかのarquments、つまりメールサーバーとポートがありません。

関連する問題