ehlo method
Issues the enhanced helo command to find out the service capabilities
EHLO or HELO always needs to be the first command that is sent to the SMTP server.
Implementation
Future<SmtpResponse> ehlo() async {
final result = await sendCommand(SmtpEhloCommand(_clientDomain));
// A fresh EHLO replaces everything announced before, in particular the
// capabilities received in clear text before STARTTLS (RFC 3207 4.2).
serverInfo
..capabilities = <String>[]
..authMechanisms = <AuthMechanism>[]
..maxMessageSize = null;
for (final line in result.responseLines) {
if (line.code == 250) {
serverInfo.capabilities.add(line.message);
if (line.message.startsWith('AUTH ')) {
if (line.message.contains('PLAIN')) {
serverInfo.authMechanisms.add(AuthMechanism.plain);
}
if (line.message.contains('LOGIN')) {
serverInfo.authMechanisms.add(AuthMechanism.login);
}
if (line.message.contains('CRAM-MD5')) {
serverInfo.authMechanisms.add(AuthMechanism.cramMd5);
}
if (line.message.contains('XOAUTH2')) {
serverInfo.authMechanisms.add(AuthMechanism.xoauth2);
}
} else if (line.message.startsWith('SIZE ')) {
final maxSizeText = line.message.substring('SIZE '.length);
serverInfo.maxMessageSize = int.tryParse(maxSizeText);
}
}
}
return result;
}