Crystalbyte.Equinox.Imap.ImapClient.Authenticate C# (CSharp) Method

Authenticate() public method

Authenticates the client to the server using the best supported SASL mechanism.
public Authenticate ( string username, string password, SaslMechanics mechanic = (SaslMechanics)0x0000 ) : bool
username string The username, obviously.
password string The users password.
mechanic SaslMechanics The SASL mechanism to use. This param is optional and can be left blank (0x0000), if done so, the best fitting mechanism will be chosen automatically.
return bool
        public bool Authenticate(string username, string password, SaslMechanics mechanic = (SaslMechanics) 0x0000)
        {
            var credentials = new NetworkCredential(username, password);
            IsAuthenticated = Authenticate(credentials, mechanic);
            return IsAuthenticated;
        }

Same methods

ImapClient::Authenticate ( NetworkCredential credentials, SaslMechanics mechanic = (SaslMechanics)0x0000 ) : bool

Usage Example

コード例 #1
0
        public static ImapClient CreateClientByAccount(Account account)
        {
            try
            {
                var client = new ImapClient { Security = account.Security };
                //client.ManualSaslAuthenticationRequired += (sender, e) => AuthenticateManually(e, account);
                var port = client.Security == SecurityPolicies.Explicit ? ImapPorts.Ssl : ImapPorts.Default;
                client.Connect(account.Host, port);
                //Thread.Sleep(100);
                client.Authenticate(account.Credential, SaslMechanics.Login);
                //Thread.Sleep(500);

                return client;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
All Usage Examples Of Crystalbyte.Equinox.Imap.ImapClient::Authenticate