다음과 같은 코드가 있습니다 (실제 이름을 게시하지 않기 위해 xxx에 고정되어 있습니다). 이 코드는 서버에 업로드 할 때 잘 작동하며 전자 메일을 완벽하게 보냅니다.메일을 보내는 것은 서버에서 작동하지만 내 로컬 컴퓨터에서는 작동하지 않습니다.
[SocketException이 (0x274d) : 내가 비주얼 스튜디오에서 내 컴퓨터에서 로컬로 테스트 할 때
MailMessage msg = new MailMessage();
msg.From = new MailAddress(fromEmailAddress_);
msg.To.Add(new MailAddress(toEmailAddress_));
msg.Subject = subject_;
msg.Body = body_;
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("[email protected]", "password");
try
{
SmtpClient c = new SmtpClient("mail.xxx.org");
c.UseDefaultCredentials = false;
c.Credentials = basicAuthenticationInfo;
c.Send(msg);
}
catch (Exception ex)
{
throw ex;
Console.Write(ex.Message.ToString());
}
하지만, 난 오류가 대상 컴퓨터가 적극적으로 66.226를 거부했기 때문에 연결하지 못했습니다. System.Net.Sockets.Socket.DoConnect (EndPoint endPointSnapshot, SocketAddress socketAddress) +239 System.Net.Sockets.Socket.InternalConnect (EndPoint remoteEP) +35 System.Net.ServicePoint.ConnectSocketInternal (Boolean connectFailure , 소켓 s4, 소켓 s6, 소켓 & 소켓, IPAddress 01 System.Net.ServicePoint.GetConnection (PooledStream PooledStream, 오브젝트 소유자 [없음 원격 서버에 연결은 WebException이, 224
가개 주소 ConnectSocketState 상태 IAsyncResult를 asyncResult, INT32 타임 아웃 예외 & 예외) 부울 비동기,하여 IPAddress & 주소, 소켓 & abortSocket, 소켓 & abortSocket6, INT32 시간 제한) 5420699 System.Net.PooledStream.Activate (owningObject, 부울 비동기, INT32 시간 제한, GeneralAsyncDelegate asyncCallback) 202 System.Net.PooledStream 객체. 활성화 (Object owningObject, GeneralAsyncDelegate asyncCallback) +21 System.Net.ConnectionPool.GetConnection (Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +332 System.Net.Mail.SmtpConnection.GetConnection (String host, Int32 port) +160 System.Net.Mail.SmtpTransport.GetConnection 문자열 호스트, INT32 포트)이 단지 자신의 호스팅 환경에서 메일을 수락하도록 공급자가 아마도 자신의 메일 서버를 방화벽있다
windows xp에는 로컬 테스트에 사용할 수있는 메일 서버 유형이 있습니까? – leora
메일 클라이언트에 구성된 ISP의 서버를 사용하십시오. – caf