discover static method
Tries to discover mail settings for the specified emailAddress.
Optionally set forceSslConnection to true when not encrypted
connections should not be allowed.
Set isLogEnabled to true to output debugging information during
the discovery process.
You can use the discovered client settings directly or by converting them to a MailAccount first with calling MailAccount.fromDiscoveredSettings.
Implementation
static Future<ClientConfig?> discover(
String emailAddress, {
bool forceSslConnection = false,
bool isLogEnabled = false,
}) async {
final config = await _discover(emailAddress, isLogEnabled);
if (forceSslConnection && config != null) {
final preferredIncomingImapServer = config.preferredIncomingImapServer;
if (preferredIncomingImapServer != null &&
!preferredIncomingImapServer.isSecureSocket) {
config.preferredIncomingImapServer =
preferredIncomingImapServer.copyWith(
port: 993,
socketType: SocketType.ssl,
);
}
final preferredIncomingPopServer = config.preferredIncomingPopServer;
if (preferredIncomingPopServer != null &&
!preferredIncomingPopServer.isSecureSocket) {
config.preferredIncomingPopServer = preferredIncomingPopServer.copyWith(
port: 995,
socketType: SocketType.ssl,
);
}
final preferredOutgoingSmtpServer = config.preferredOutgoingSmtpServer;
if (preferredOutgoingSmtpServer != null &&
!preferredOutgoingSmtpServer.isSecureSocket) {
config.preferredOutgoingSmtpServer =
preferredOutgoingSmtpServer.copyWith(
port: 465,
socketType: SocketType.ssl,
);
}
}
return config;
}