From 62fabef95549ef0de1fd8b0a7dd3671e4c820ec6 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 31 Jan 2020 12:06:18 +0100 Subject: [PATCH] Handle MX record not resolving --- .../java/eu/faircode/email/EmailProvider.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EmailProvider.java b/app/src/main/java/eu/faircode/email/EmailProvider.java index 0526ed20e1..5b86301fd0 100644 --- a/app/src/main/java/eu/faircode/email/EmailProvider.java +++ b/app/src/main/java/eu/faircode/email/EmailProvider.java @@ -221,21 +221,25 @@ public class EmailProvider { } 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); + try { + // 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) - break; + } catch (Throwable ex1) { + Log.w(ex1); } if (autoconfig == null)