2011-12-23 8 views
5

ローカルホストからOK働くコントローラのコードです:私はそれが唯一の本番サーバ上で失敗したと述べたようは、Googleからの電子メールを送信すると、本番サーバー上で失敗しますが、ここで

[HttpPost, ValidateInput(true)] 
     public ActionResult Contact(ContactForm model) 
     { 
      if (!ModelState.IsValid) 
      { 
       return Json("error"); 

      } 
      else 
      { 

       WebMail.SmtpServer = "smtp.gmail.com"; 
       WebMail.UserName = //email here 
       WebMail.Password = //password here 
       WebMail.EnableSsl = true; 

       string message = model.Name + " " + model.Telephone + " " + model.Email + " " + model.Address + " " + model.City + " " + model.ZipCode; 

       try 
       { 
        WebMail.Send("[email protected]", "philaslim.com/info email", message, model.Email); 
        return Json("thanks"); 
       } 
       catch (Exception ex) 
       { 
        return Json(ex.Message.ToString()); 
       } 

      } 

。返された例外メッセージは "Failure sending sending mail"です。何か案は?

EDIT:のInnerException:

System.Net.WebException:リモートサーバーに接続できません---> System.Net.Sockets.SocketException:接続されているパーティが正しく応答しなかったため、接続の試行が失敗しました接続されたホストがSystem.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot、SocketAddress socketAddress)の74.125.53.108:25(System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure、ソケットs4、ソケットs6、ソケット&ソケット、IPAddress &アドレス、ConnectSocketState状態、IAsyncResult asyncResult、Int32タイムアウト、例外&例外)---内部eの終了xceptionスタックトレース--- System.Net.ServicePoint.GetConnection(PooledStream PooledStream、Object owner、Boolean async、IPAddress &アドレス、ソケット& abortSocket、ソケット& abortSocket6、Int32タイムアウト)at System.Net.PooledStream.Activate(Object owningObject 、System.Net.ConnectionPool.GetConnection(Object owningObject、GeneralAsyncDelegate asyncCallback、Int32 creationTimeout)のSystem.Net.PooledStream.Activate(Object owningObject、GeneralAsyncDelegate asyncCallback)のSystem.Net.Mailでのブール値の非同期、Int32タイムアウト、 SmtpConnection.GetConnection(ServicePoint servicePoint)at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)System.Net.Mail.SmtpClient.GetConnection()System.Net.Mail.SmtpClient.Send(MailMessageメッセージ)

+1

InnerExceptionには何かがありますか? – Lester

+0

編集してください –

+0

プロダクションサーバーでインターネットにアクセスするにはプロキシが必要ですか? – hawkke

答えて

6

あなたの発信SMTPポート(25,587)がおそらくあなたのサーバーで閉じられている場合は、ファイアウォールの設定を確認してください。

+0

私はgodaddyを使用しています。私はそれらを私が推測する必要があります。 –

+0

あなたは私の人生を救った - これは数時間で完了します!どうもありがとう! –

関連する問題