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)); }
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.AUTHFAILED); return(IsAuthenticated); }
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"); } }
public async Task <string> GetFolders() { return(await ExecuteCommand(ImapCommands.ListFolders())); }