Gmail receives emails from sent items

I have the following code to connect to the mailbox of the mail server:

Store popStore = popSession.getStore("pop3"); popStore.connect(address, userName, password); Folder inboxFolder = popStore.getFolder("Inbox"); 

To post this, I am checking for new letters. Now, when I connect to Gmail, I get emails from sent items, but in fact it should only be from the Inbox. With Yahoo, this works fine.

Any idea what might cause this problem in Gmail?

Edit: I also tried with INBOX, and the result is the same

+6
source share
4 answers

The following is a snippet of code. When I checked with gmail, there are no matches between the mailbox and the sent mail. (It should have been a comment, a message as an answer for formatting)

 javax.mail.Folder[] folders = store.getDefaultFolder().list("*"); for (javax.mail.Folder folder : folders) { if ((folder.getType() & javax.mail.Folder.HOLDS_MESSAGES) != 0) { if (folder.getFullName().equalsIgnoreCase("[Gmail]/Sent Mail") || folder.getFullName().equalsIgnoreCase("Inbox")) { System.out.println(folder.getFullName() + ": " + folder.getMessageCount()); folder.open(Folder.READ_ONLY); for (Message m : folder.getMessages( folder.getMessageCount() - 5, folder.getMessageCount())) { System.out.println("m.getSubject() = " + m.getSubject()); } folder.close(true); } } } 
+4
source

try it

 Folder folder = store.getDefaultFolder(); folder = folder.getFolder("INBOX"); folder.open(Folder.READ_WRITE); 
+3
source

An interesting problem. I did a little research and found this post in which Google says:

When you enable POP, all messages are downloaded to your client, with the exception of spam, trash and chats. If you do not want to send messages sent from the web interface, downloaded to the mailbox of the mail client, we suggest creating a filter in your client.

To create a filter by the sender, you can do this:

 String filter = "Not([SenderEmailAddress] = ' XXXXX@gmail.com ')"; Items inboxItems = inboxFolder.Items.Restrict(filter); 

where XXXXX@gmail.com is your email address. This filter will only give you items that are sent by someone other than you. You can also replace the Restrict method with Find , but Restrict will be much faster for large datasets.

+3
source

when you exchange messages using a reply or a reply to everyone in gmail, it will be considered a mailbox. Because it's a conversation. so your sent letter is also a mailbox. therefore you will receive messages in your messages.

Read this official Google answer.

+2
source

Source: https://habr.com/ru/post/949455/


All Articles