Exemplo n.º 1
0
        public async Task <bool> SelectFolder(string folder)
        {
            var result = await ExecuteCommand(ImapCommands.SelectFolder(folder));

            //Double check, some servers sometimes include a last line with a & OK appending extra info when command fails
            return(result.Contains(ImapResponse.OK) && !result.Contains(ImapResponse.ERROR));
        }
Exemplo n.º 2
0
        public async Task <bool> AuthenticateAsync(string user, string password)
        {
            if (ConnectionType == ImapConnectionType.STARTTLS)
            {
                await UpgradeToSecureConnection();
            }

            var result = await ExecuteCommand(ImapCommands.Login(user, password));

            IsAuthenticated = result.Contains(ImapResponse.OK);
            return(IsAuthenticated);
        }
Exemplo n.º 3
0
        private async Task <bool> UpgradeToSecureConnection()
        {
            var commandResult = await ExecuteCommand(ImapCommands.StartTLS());

            var upgradeSuccess = commandResult.Contains(ImapResponse.OK_TLS_NEGOTIATION);

            if (upgradeSuccess)
            {
                ConnectionType = ImapConnectionType.SSL_TLS;
                _stream        = GetStream();
                return(true);
            }
            else
            {
                throw new Exception("Could not upgrade IMAP non SSL connection using STARTTLS handshake");
            }
        }
Exemplo n.º 4
0
 public async Task <string> GetFolders()
 {
     return(await ExecuteCommand(ImapCommands.ListFolders()));
 }