Alpha 7
This commit is contained in:
@@ -17,7 +17,13 @@ final class IMAPClient {
|
||||
let greeting = try await connection.readLine()
|
||||
if greeting.uppercased().hasPrefix("* PREAUTH") { return }
|
||||
guard greeting.uppercased().hasPrefix("* OK") else { throw MailError.message("IMAP: \(greeting)") }
|
||||
_ = try await command("LOGIN \(Self.quote(account.username)) \(Self.quote(password))")
|
||||
let capabilities = greeting.uppercased()
|
||||
if capabilities.contains("AUTH=PLAIN"), capabilities.contains("SASL-IR") {
|
||||
let credentials = Data(("\0" + account.username + "\0" + password).utf8).base64EncodedString()
|
||||
_ = try await command("AUTHENTICATE PLAIN \(credentials)")
|
||||
} else {
|
||||
_ = try await command("LOGIN \(Self.quote(account.username)) \(Self.quote(password))")
|
||||
}
|
||||
}
|
||||
|
||||
static func quote(_ value: String) throws -> String {
|
||||
|
||||
Reference in New Issue
Block a user