public Boolean AuthenticateByAPop() { String s = ""; String TimeStamp = ""; Int32 StartIndex = 0; Int32 EndIndex = 0; if (this.EnsureOpen() == Pop3ConnectionState.Connected) { s = this.Execute("user " + this._UserName, false); if (s.StartsWith("+OK") == true) { if (s.IndexOf("<") > -1 && s.IndexOf(">") > -1) { StartIndex = s.IndexOf("<"); EndIndex = s.IndexOf(">"); TimeStamp = s.Substring(StartIndex, EndIndex - StartIndex + 1); s = this.Execute("pass " + MailParser.ToMd5DigestString(TimeStamp + this._Password), false); if (s.StartsWith("+OK") == true) { this._State = Pop3ConnectionState.Authenticated; } } } } return(this._State == Pop3ConnectionState.Authenticated); }
/// POP3メールサーバーへAPOP認証でログインします。 /// <summary> /// Log in to pop3 server by A-POP authenticate and return login success or failure as bool. /// POP3メールサーバーへAPOP認証でログインします。 /// </summary> /// <returns></returns> public Boolean TryAuthenticateByAPop() { Pop3CommandResult rs = null; String TimeStamp = ""; Int32 StartIndex = 0; Int32 EndIndex = 0; if (this.EnsureOpen() == Pop3ConnectionState.Connected) { //ユーザー名送信 rs = this.Execute("user " + this.UserName, false); if (rs.Ok == true) { if (rs.Text.IndexOf("<") > -1 && rs.Text.IndexOf(">") > -1) { StartIndex = rs.Text.IndexOf("<"); EndIndex = rs.Text.IndexOf(">"); TimeStamp = rs.Text.Substring(StartIndex, EndIndex - StartIndex + 1); //パスワード送信 rs = this.Execute("pass " + Cryptography.ToMd5DigestString(TimeStamp + this.Password), false); if (rs.Ok == true) { this._State = Pop3ConnectionState.Authenticated; } } } } return(this._State == Pop3ConnectionState.Authenticated); }
private TcpClient GetTcpClient() { TcpClient tc = null; IPHostEntry hostEntry = null; hostEntry = this.GetHostEntry(); if (hostEntry != null) { foreach (IPAddress address in hostEntry.AddressList) { tc = this.TryGetTcpClient(address); if (tc != null) { break; } } } if (tc == null) { this._State = Pop3ConnectionState.Disconnected; return(null); } this._State = Pop3ConnectionState.Connected; return(tc); }
public Boolean AuthenticateByPop() { String s = ""; if (this.EnsureOpen() == Pop3ConnectionState.Connected) { s = this.Execute("user " + this._UserName, false); if (s.StartsWith("+OK") == true) { s = this.Execute("pass " + this._Password, false); if (s.StartsWith("+OK") == true) { this._State = Pop3ConnectionState.Authenticated; } } } return(this._State == Pop3ConnectionState.Authenticated); }
/// POP3メールサーバーへPOP認証でログインします。 /// <summary> /// Log in to pop3 server by POP authenticate and return login success or failure as bool. /// POP3メールサーバーへPOP認証でログインします。 /// </summary> /// <returns></returns> public Boolean TryAuthenticateByPop() { Pop3CommandResult rs = null; if (this.EnsureOpen() == Pop3ConnectionState.Connected) { //ユーザー名送信 rs = this.Execute("user " + this.UserName, false); if (rs.Ok == true) { //パスワード送信 rs = this.Execute("pass " + this.Password, false); if (rs.Ok == true) { this._State = Pop3ConnectionState.Authenticated; } } } return(this._State == Pop3ConnectionState.Authenticated); }
/// サーバーへの接続を開きます。 /// <summary> /// Open connection to a server. /// サーバーへの接続を開きます。 /// </summary> public Pop3ConnectionState Open() { if (this.Connect() == true) { var s = this.GetResponse(); if (s.StartsWith("+OK") == true) { this._State = Pop3ConnectionState.Connected; } else { this.Socket = null; this.Stream = null; this._State = Pop3ConnectionState.Disconnected; } } else { this._State = Pop3ConnectionState.Disconnected; } return(this._State); }
public Pop3ConnectionState Open() { this._TcpClient = this.GetTcpClient(); if (this._TcpClient == null) { this._State = Pop3ConnectionState.Disconnected; } else { if (this._Ssl == true) { SslStream ssl = new SslStream(this._TcpClient.GetStream(), false, this.RemoteCertificateValidationCallback); ssl.AuthenticateAsClient(this._ServerName); if (ssl.IsAuthenticated == false) { this._State = Pop3ConnectionState.Disconnected; this._TcpClient = null; return(this._State); } this._Stream = ssl; } else { this._Stream = this._TcpClient.GetStream(); } if (this.GetResponse().StartsWith("+OK") == true) { this._State = Pop3ConnectionState.Connected; } else { this._TcpClient = null; this._State = Pop3ConnectionState.Disconnected; } } return(this._State); }
public void Close() { this._TcpClient.Close(); this._State = Pop3ConnectionState.Disconnected; }
/// サーバーへの接続を開きます。 /// <summary> /// Open connection to a server. /// サーバーへの接続を開きます。 /// </summary> public Pop3ConnectionState Open() { if (this.Connect() == true) { var s = this.GetResponse(); if (s.Ok == true) { this.State = Pop3ConnectionState.Connected; } else { this.Close(); } } else { this.State = Pop3ConnectionState.Disconnected; } return this._State; }
/// メールサーバーとの接続を切断します。 /// <summary> /// disconnect connection to pop3 server. /// メールサーバーとの接続を切断します。 /// </summary> public override void Close() { base.Close(); this._State = Pop3ConnectionState.Disconnected; }
/// POP3メールサーバーへPOP認証でログインします。 /// <summary> /// Log in to pop3 server by POP authenticate and return login success or failure as bool. /// POP3メールサーバーへPOP認証でログインします。 /// </summary> /// <returns></returns> public Boolean TryAuthenticateByPop() { Pop3CommandResult rs = null; if (this.EnsureOpen() == Pop3ConnectionState.Connected) { //ユーザー名送信 rs = this.Execute("user " + this.UserName, false); if (rs.Ok == true) { //パスワード送信 rs = this.Execute("pass " + this.Password, false); if (rs.Ok == true) { this._State = Pop3ConnectionState.Authenticated; } } } return this._State == Pop3ConnectionState.Authenticated; }
/// POP3メールサーバーへAPOP認証でログインします。 /// <summary> /// Log in to pop3 server by A-POP authenticate and return login success or failure as bool. /// POP3メールサーバーへAPOP認証でログインします。 /// </summary> /// <returns></returns> public Boolean TryAuthenticateByAPop() { Pop3CommandResult rs = null; String TimeStamp = ""; Int32 StartIndex = 0; Int32 EndIndex = 0; if (this.EnsureOpen() == Pop3ConnectionState.Connected) { //ユーザー名送信 rs = this.Execute("user " + this.UserName, false); if (rs.Ok == true) { if (rs.Text.IndexOf("<") > -1 && rs.Text.IndexOf(">") > -1) { StartIndex = rs.Text.IndexOf("<"); EndIndex = rs.Text.IndexOf(">"); TimeStamp = rs.Text.Substring(StartIndex, EndIndex - StartIndex + 1); //パスワード送信 rs = this.Execute("pass " + Cryptography.ToMd5DigestString(TimeStamp + this.Password), false); if (rs.Ok == true) { this._State = Pop3ConnectionState.Authenticated; } } } } return this._State == Pop3ConnectionState.Authenticated; }
/// メールサーバーとの接続を切断します。 /// <summary> /// disconnect connection to pop3 server. /// メールサーバーとの接続を切断します。 /// </summary> public void Close() { this.Socket.Close(); this._State = Pop3ConnectionState.Disconnected; }