private static void AuthenticateContinueCallback(IAsyncResult result) { if (!result.CompletedSynchronously) { SmtpConnection.ConnectAndHandshakeAsyncResult asyncState = (SmtpConnection.ConnectAndHandshakeAsyncResult)result.AsyncState; try { LineInfo info = AuthCommand.EndSend(result); if (info.StatusCode == ((SmtpStatusCode)0xeb)) { asyncState.connection.authenticationModules[asyncState.currentModule].CloseContext(asyncState.connection); asyncState.connection.isConnected = true; asyncState.InvokeCallback(); } else { if (info.StatusCode == ((SmtpStatusCode)0x14e)) { asyncState.authResponse = info.Line; if (!asyncState.AuthenticateContinue()) { return; } } asyncState.Authenticate(); } } catch (Exception exception) { asyncState.InvokeCallback(exception); } } }
private static void SendEHelloCallback(IAsyncResult result) { if (!result.CompletedSynchronously) { SmtpConnection.ConnectAndHandshakeAsyncResult asyncState = (SmtpConnection.ConnectAndHandshakeAsyncResult)result.AsyncState; try { try { asyncState.connection.extensions = EHelloCommand.EndSend(result); asyncState.connection.ParseExtensions(asyncState.connection.extensions); if (asyncState.connection.pooledStream.NetworkStream is TlsStream) { asyncState.Authenticate(); return; } } catch (SmtpException exception) { if ((exception.StatusCode != SmtpStatusCode.CommandUnrecognized) && (exception.StatusCode != SmtpStatusCode.CommandNotImplemented)) { throw exception; } if (!asyncState.SendHello()) { return; } } if (asyncState.connection.EnableSsl) { if (!asyncState.connection.serverSupportsStartTls && !(asyncState.connection.pooledStream.NetworkStream is TlsStream)) { throw new SmtpException(SR.GetString("MailServerDoesNotSupportStartTls")); } asyncState.SendStartTls(); } else { asyncState.Authenticate(); } } catch (Exception exception2) { asyncState.InvokeCallback(exception2); } } }
private static void SendHelloCallback(IAsyncResult result) { if (!result.CompletedSynchronously) { SmtpConnection.ConnectAndHandshakeAsyncResult asyncState = (SmtpConnection.ConnectAndHandshakeAsyncResult)result.AsyncState; try { HelloCommand.EndSend(result); asyncState.Authenticate(); } catch (Exception exception) { asyncState.InvokeCallback(exception); } } }