mirror of https://github.com/M66B/FairEmail.git
Use all available methods to scan MX host
This commit is contained in:
parent
e9c19ff2a4
commit
7751c5ea6e
|
@ -215,7 +215,32 @@ public class EmailProvider {
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmailProvider autoconfig = _fromDomain(context, domain.toLowerCase(Locale.ROOT), email, discover);
|
EmailProvider autoconfig = null;
|
||||||
|
try {
|
||||||
|
autoconfig = _fromDomain(context, domain.toLowerCase(Locale.ROOT), email, discover);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.w(ex);
|
||||||
|
|
||||||
|
// Retry at MX server addresses
|
||||||
|
Record[] records = lookupDNS(context, domain, Type.MX);
|
||||||
|
for (Record record : records) {
|
||||||
|
String target = ((MXRecord) record).getTarget().toString(true);
|
||||||
|
while (autoconfig == null && target != null && target.indexOf('.') > 0) {
|
||||||
|
try {
|
||||||
|
autoconfig = _fromDomain(context, target.toLowerCase(Locale.ROOT), email, discover);
|
||||||
|
} catch (Throwable ex1) {
|
||||||
|
Log.w(ex1);
|
||||||
|
int dot = target.indexOf('.');
|
||||||
|
target = target.substring(dot + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (autoconfig != null)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (autoconfig == null)
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
// Always prefer built-in profiles
|
// Always prefer built-in profiles
|
||||||
// - ISPDB is not always correct
|
// - ISPDB is not always correct
|
||||||
|
@ -263,31 +288,6 @@ public class EmailProvider {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private static EmailProvider fromISPDB(Context context, String domain, String email) throws IOException, XmlPullParserException {
|
private static EmailProvider fromISPDB(Context context, String domain, String email) throws IOException, XmlPullParserException {
|
||||||
try {
|
|
||||||
return _fromISPDB(context, domain, email);
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
Log.w(ex);
|
|
||||||
|
|
||||||
Record[] records = lookupDNS(context, domain, Type.MX);
|
|
||||||
for (Record record : records) {
|
|
||||||
String target = ((MXRecord) record).getTarget().toString(true);
|
|
||||||
while (target != null && target.indexOf('.') > 0) {
|
|
||||||
try {
|
|
||||||
return _fromISPDB(context, target, email);
|
|
||||||
} catch (Throwable ex1) {
|
|
||||||
Log.w(ex1);
|
|
||||||
int dot = target.indexOf('.');
|
|
||||||
target = target.substring(dot + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new UnknownHostException(domain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private static EmailProvider _fromISPDB(Context context, String domain, String email) throws IOException, XmlPullParserException {
|
|
||||||
// https://wiki.mozilla.org/Thunderbird:Autoconfiguration
|
// https://wiki.mozilla.org/Thunderbird:Autoconfiguration
|
||||||
try {
|
try {
|
||||||
URL url = new URL("https://autoconfig." + domain + "/mail/config-v1.1.xml?emailaddress=" + email);
|
URL url = new URL("https://autoconfig." + domain + "/mail/config-v1.1.xml?emailaddress=" + email);
|
||||||
|
|
Loading…
Reference in New Issue