From 7d4429bd662ce3d5c06f768fc5a9b8caf28e8a92 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 22 May 2024 11:21:42 +0200 Subject: [PATCH] Receive before sending --- app/src/main/java/eu/faircode/email/FragmentIdentity.java | 8 ++++++++ app/src/main/java/eu/faircode/email/ServiceSend.java | 8 ++++++++ app/src/main/res/values/strings.xml | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index 27aa301211..122b2efdb4 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -76,6 +76,7 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; +import javax.mail.Folder; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; @@ -1115,6 +1116,13 @@ public class FragmentIdentity extends FragmentBase { if (a != null) try (EmailService iaccount = new EmailService(context, a, EmailService.PURPOSE_CHECK, true)) { iaccount.connect(a); + Folder ifolder = iaccount.getStore().getFolder("INBOX"); + ifolder.open(Folder.READ_ONLY); + try { + ifolder.getMessages(); + } finally { + ifolder.close(); + } } } diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java index caffd93110..5c8f169f4d 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSend.java +++ b/app/src/main/java/eu/faircode/email/ServiceSend.java @@ -67,6 +67,7 @@ import java.util.concurrent.ExecutorService; import javax.mail.Address; import javax.mail.AuthenticationFailedException; +import javax.mail.Folder; import javax.mail.MessageRemovedException; import javax.mail.MessagingException; import javax.mail.SendFailedException; @@ -803,6 +804,13 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar if (account != null) try (EmailService iaccount = new EmailService(this, account, EmailService.PURPOSE_USE, debug)) { iaccount.connect(account); + Folder ifolder = iaccount.getStore().getFolder("INBOX"); + ifolder.open(Folder.READ_ONLY); + try { + ifolder.getMessages(); + } finally { + ifolder.close(); + } } EmailService iservice = new EmailService(this, ident, EmailService.PURPOSE_USE, debug); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e812616b24..9986a25830 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1245,7 +1245,7 @@ Password How are passwords stored? Usernames and passwords are usually case sensitive - Login before sending + Receive before sending Client certificate Realm Use local IP address instead of host name