login method
Logs in the user with the given name and password.
Requires the IMAP service to support AUTH=PLAIN capability.
Implementation
Future<List<Capability>> login(String name, String password) async {
// RFC 3501: quoted strings may only contain 7-bit text without CR or LF
// and need " and \ escaped, anything else has to be sent as a literal.
final parts = <String>[];
final line = StringBuffer('LOGIN ');
_writeImapString(line, parts, name);
line.write(' ');
_writeImapString(line, parts, password);
parts.add(line.toString());
final logText =
'LOGIN ${_canBeQuoted(name) ? _quote(name) : '{literal}'} '
'"(password scrambled)"';
final cmd = parts.length == 1
? Command(
parts.first,
logText: logText,
writeTimeout: defaultWriteTimeout,
responseTimeout: defaultResponseTimeout,
)
: Command.withContinuation(
parts,
logText: logText,
writeTimeout: defaultWriteTimeout,
responseTimeout: defaultResponseTimeout,
);
final parser = CapabilityParser(serverInfo);
final response = await sendCommand<List<Capability>>(cmd, parser);
isLoggedIn = true;
return response;
}