私はC#を使用して電子メールを送信しています。自分のウェブサイトにGoDaddyのサーバーを使用しました。それは(2013 VS)ローカルホスト上で作業している、しかし、サーバー上で同じコードを展開する際には、次のエラーを与える:ローカルホストでは電子メール送信コードが動作しますが、サーバにはありません
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 [2607:f8b0:400e:c05::6c]:25
説明:未処理の例外は、現在のWebの実行中に発生しました要求。エラーの詳細とコード内のどこで発生したのかについては、スタックトレースを参照してください。
例外の詳細: System.Net.Sockets.SocketException:接続先が適切に一定期間後に応答、または接続されたホストは、[2607の応答に失敗したため、接続が失敗確立していないため、接続の試行が失敗:f8b0 :400E:C05 :: 6cは]:25
スタックトレース:
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed t SMS.Portal.SendSMS.btnSubmit_Click(Object sender, EventArgs e) in d:\Paul\ProximityMarketer\smsproximitysource\source\Portal\SendSMS.aspx.cs:30 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9633514 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103 System.Web.UI.WebControls.Button.System.Web...IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
バージョン情報:Microsoft .NET Frameworkのバージョン:4.0.30319; ASP.NETのバージョン:4.0.30319.34280
コードは以下のとおりである:
SmtpClient smtpclient = new SmtpClient();
smtpclient.Host = "smtp.gmail.com";
smtpclient.Port = 25;
smtpclient.Credentials = new NetworkCredential("[email protected]", "Password");
smtpclient.EnableSsl = true;
MailMessage objmsg = new MailMessage();
objmsg.From = new MailAddress("[email protected]");
objmsg.To.Add(email);
objmsg.Subject = "testing";
objmsg.Body = myString.ToString();
objmsg.IsBodyHtml = true;
smtpclient.Send(objmsg);
'smtpclient.Port = 25;'パブリックホスティングサーバーでポート25を使用できますか? – vendettamit
おそらく、ホストされたサーバーでこれをブロックするファイアウォールはありますか? –
gmailは安全でないメールであるポート25を使用しません。ポート番号587のTLSを使用する必要があります。wbpage:https://support.google.com/a/answer/2956491 – jdweng