From 01a9f4a51f442bd2dc3dd27ea65cc6923d9b03a1 Mon Sep 17 00:00:00 2001 From: aleksandrmozgovoi Date: Mon, 23 Jul 2018 21:26:22 +0300 Subject: [PATCH 1/3] Update GmailSender.java Fix CertPathValidatorException. --- .../gmailbackgroundlibrary/util/GmailSender.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gmailbackgroundlibrary/src/main/java/com/creativityapps/gmailbackgroundlibrary/util/GmailSender.java b/gmailbackgroundlibrary/src/main/java/com/creativityapps/gmailbackgroundlibrary/util/GmailSender.java index 227f43a..3ae6506 100755 --- a/gmailbackgroundlibrary/src/main/java/com/creativityapps/gmailbackgroundlibrary/util/GmailSender.java +++ b/gmailbackgroundlibrary/src/main/java/com/creativityapps/gmailbackgroundlibrary/util/GmailSender.java @@ -38,7 +38,15 @@ public class GmailSender extends javax.mail.Authenticator { public GmailSender(String user, String password, boolean useDefaultSession) { this.user = user; this.password = password; - + + MailSSLSocketFactory socketFactory = null; + try { + socketFactory = new MailSSLSocketFactory(); + socketFactory.setTrustAllHosts(true); + } catch (GeneralSecurityException e) { + e.printStackTrace(); + } + Properties props = new Properties(); props.setProperty("mail.transport.protocol", "smtp"); props.setProperty("mail.host", GMAIL_HOST); @@ -48,6 +56,8 @@ public GmailSender(String user, String password, boolean useDefaultSession) { props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.socketFactory.fallback", "false"); props.setProperty("mail.smtp.quitwait", "false"); + props.put("mail.smtps.socketFactory", socketFactory); + props.put("mail.smtp.ssl.trust", "smtp.gmail.com"); session = useDefaultSession ? Session.getDefaultInstance(props, this) : Session.getInstance(props, this); _multipart = new MimeMultipart(); @@ -146,4 +156,4 @@ public OutputStream getOutputStream() throws IOException { throw new IOException("Not Supported"); } } -} \ No newline at end of file +} From 5a1b21ede6f6dc41242b47517fe8477623cacd08 Mon Sep 17 00:00:00 2001 From: aleksandrmozgovoi Date: Mon, 23 Jul 2018 22:15:33 +0300 Subject: [PATCH 2/3] Update build.gradle --- gmailbackgroundlibrary/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gmailbackgroundlibrary/build.gradle b/gmailbackgroundlibrary/build.gradle index f5934e0..3613c63 100644 --- a/gmailbackgroundlibrary/build.gradle +++ b/gmailbackgroundlibrary/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 11 targetSdkVersion 25 - versionCode 2 - versionName "1.1" + versionCode 3 + versionName "1.2" } buildTypes { release { From dac2f517b7bb5e83cc1536972d3641491888aefa Mon Sep 17 00:00:00 2001 From: aleksandrmozgovoi Date: Mon, 23 Jul 2018 22:26:43 +0300 Subject: [PATCH 3/3] test --- gmailbackgroundlibrary/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gmailbackgroundlibrary/build.gradle b/gmailbackgroundlibrary/build.gradle index 3613c63..f5934e0 100644 --- a/gmailbackgroundlibrary/build.gradle +++ b/gmailbackgroundlibrary/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 11 targetSdkVersion 25 - versionCode 3 - versionName "1.2" + versionCode 2 + versionName "1.1" } buildTypes { release {