Added protocol hint

This commit is contained in:
M66B
2020-06-19 18:35:42 +02:00
parent 7097debe93
commit f07374fa08
2 changed files with 12 additions and 0 deletions

View File

@@ -73,6 +73,8 @@ import javax.mail.event.StoreListener;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
@@ -369,6 +371,15 @@ public class EmailService implements AutoCloseable {
} catch (MessagingException ex) {
if (port == 995 && !("pop3".equals(protocol) || "pop3s".equals(protocol)))
throw new MessagingException(context.getString(R.string.title_service_port), ex);
else if (ex.getMessage() != null &&
ex.getMessage().contains("Got bad greeting"))
throw new MessagingException(context.getString(R.string.title_service_protocol), ex);
else if (ex.getCause() instanceof SSLException &&
ex.getCause().getMessage() != null &&
ex.getCause().getMessage().contains("Unable to parse TLS packet header"))
throw new MessagingException(context.getString(R.string.title_service_protocol), ex);
else if (ex.getCause() instanceof SSLHandshakeException)
throw new MessagingException(context.getString(R.string.title_service_protocol), ex);
else
throw ex;
}