2013-08-22 3 views
0

У меня появилось следующее сообщение об ошибке, когда я попытался отправить сообщение с помощью smtp.Ошибка при попытке отправить почту с помощью smtp

 
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 67.69.240.69:25 
System.Net.WebException: Unable to connect to the remote server ---> 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 67.69.240.69:25 
    at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) 
    at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) 
    --- End of inner exception stack trace --- 
    at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) 
    at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) 
    at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) 
    at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) 
    at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) 
    at System.Net.Mail.SmtpClient.Send(MailMessage message) 
    --- End of inner exception stack trace --- 
    at System.Net.Mail.SmtpClient.Send(MailMessage message) 
    at Handler.BLL.cSendMail.SendMail(String p_strFrom, String p_strDisplayName, String p_strTo, String p_strSubject, String p_strMessage, String strFileName) 
[ staffID:,21/08/2013 9:49:34 AM ]: status code : GeneralFailure

код

public bool SendMail(string p_strFrom, string p_strDisplayName, string p_strTo, string p_strSubject, string p_strMessage , string strFileName) 
{ 
    try 
    { 
     p_strDisplayName = _DisplayName; 
     string smtpserver = _SmtpServer; 
     SmtpClient smtpClient = new SmtpClient(); 
     MailMessage message = new MailMessage(); 
     MailAddress fromAddress = new MailAddress(_From,_DisplayName); 
     smtpClient.Host = _SmtpServer; 
     smtpClient.Port = Convert.ToInt32(_Port); 
     string strAuth_UserName = _UserName; 
     string strAuth_Password = _Password; 
     if (strAuth_UserName != null) 
     { 
      System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(strAuth_UserName, strAuth_Password); 
      smtpClient.UseDefaultCredentials = false; 
      if (_SSL) 
      { 
       smtpClient.EnableSsl = true; 
      } 
      smtpClient.Credentials = SMTPUserInfo; 
     } 
     message.From = fromAddress; 

     message.Subject = p_strSubject; 
     message.IsBodyHtml = true; 
     message.Body = p_strMessage; 
     message.To.Add(p_strTo); 
     try 
     { 
      smtpClient.Send(message); 
      Log.WriteSpecialLog("smtpClient mail sending first try success", ""); 
     } 
      catch (Exception ee) 
     { 
      Log.WriteSpecialLog("smtpClient mail sending first try Failed : " + ee.ToString(), ""); 
      return false; 
     } 
     return true; 
    } 
    catch (Exception ex) 
    { 
     Log.WriteLog("smtpClient mail sending overall failed : " + ex.ToString()); 
     return false; 
    } 
} 

, когда 3 или более отправка почты только один или два не может

+0

Как насчет вставки кода – Rohit

ответ

1

Я считаю, что он должен делать с порт заходящего

Попробуйте настроить Port to 587 вместо port 25, а также посмотреть на this

+0

Я использую сервер smtp10.on.aibn.com. Можно ли установить 587? – JIKKU

1

Как только я попал в ту же ошибку и обнаружил, что порт 25 заблокирован антивирусом, который я установил в системе. Я просто отключил его. Если ваш smtp размещен на другом компьютере или это сторонний хостинг, вы должны уточнить, является ли порт 25 разблокированным или нет.

Смежные вопросы