I have enabled POP3 settings for my gmail. I am able to connect to the POP3 store using my password in a Java app. I have around 10k messages in my inbox.
When I cal
Not a real answer, but I got around this by using Mailkit's IMAP. Also, this is C#, not Java code, but maybe it can help people running into the same problem:
var emails = new List();
using (var client = new ImapClient())
{
client.Connect("imap.gmail.com", _smtpConfig.SSLIMAPPort, SecureSocketOptions.SslOnConnect);
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate(smtpConfig.PopUsername, smtpConfig.PopPassword);
client.Inbox.Open(FolderAccess.ReadWrite);
var items = client.Inbox.Fetch(0, -1, MessageSummaryItems.UniqueId | MessageSummaryItems.BodyStructure);
foreach (var item in items)
{
if (item.TextBody != null)
{
var mime = (TextPart)client.Inbox.GetBodyPart(item.UniqueId, item.TextBody);
var text = mime.Text;
var email = new EmailMessage
{
Body = text
};
emails.Add(email);
}
}
client.Disconnect(true);
}
return emails;
Thanks to jstedfast - it was all done using his docs.