From bcd56f87719f86695bfbd42e788a4a17c2e1484d Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 14 Mar 2020 13:20:25 +0100 Subject: [PATCH] Revert "Some devices seem not to be able to connect to plain IP addresses" This reverts commit 60b4f302e2ccafeb3626e0eb41991c60208c4495. --- app/src/main/java/eu/faircode/email/EmailService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EmailService.java b/app/src/main/java/eu/faircode/email/EmailService.java index 4cd7900b5b..29d60c3d59 100644 --- a/app/src/main/java/eu/faircode/email/EmailService.java +++ b/app/src/main/java/eu/faircode/email/EmailService.java @@ -360,13 +360,17 @@ public class EmailService implements AutoCloseable { private void connect( String host, int port, String user, String password, SSLSocketFactoryService factory) throws MessagingException { + InetAddress main = null; try { //if (BuildConfig.DEBUG) // throw new MailConnectException( // new SocketConnectException("Debug", new IOException("Test"), host, port, 0)); - EntityLog.log(context, "Connecting to " + host); - _connect(host, port, user, password, factory); + main = InetAddress.getByName(host); + EntityLog.log(context, "Connecting to " + main); + _connect(main.getHostAddress(), port, user, password, factory); + } catch (UnknownHostException ex) { + throw new MessagingException("Unknown host " + host, ex); } catch (MessagingException ex) { boolean ioError = false; Throwable ce = ex; @@ -381,7 +385,6 @@ public class EmailService implements AutoCloseable { if (ioError) { try { // Some devices resolve IPv6 addresses while not having IPv6 connectivity - InetAddress main = InetAddress.getByName(host); InetAddress[] iaddrs = InetAddress.getAllByName(host); boolean ip4 = (main instanceof Inet4Address); boolean ip6 = (main instanceof Inet6Address);