jakartaee / jakartaee/mail-api
[BUG] POP3, Email is deleted from the server when calling any function on MimeMultipart Object, even when READ_ONLY is set on folder
Open
@jbescos is already working on this.
Since Sep 30, 2024.
- Dominant language
- Java
- Stars
- 285
- Forks
- 109
- Avg merge
- 15h 19m
- Merged PRs (30d)
- 1
Description
Describe the bug
When trying to read all the content of an email, the email is deleted.
It seems to happens whatever the function we call on MimeMultipart
To Reproduce
Steps to reproduce the behavior:
Properties properties = new Properties();
properties.put("mail.store.protocol", "pop3s");
properties.put("mail.pop3s.host", "pop.gmail.com");
properties.put("mail.pop3s.port", "995");
properties.put("mail.pop3s.auth", true);
properties.put("mail.pop3s.starttls.enable", true);
Session session = Session.getInstance(properties);
Store store = session.getStore();
store.connect("anyAddress@gmail.com", "password");
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
// Let's say we have 20 messages.
System.out.println("NB of elements: " + folder.getMessageCount());
Message message = folder.getMessages()[0];
MimeMultipart mimeMultipart = (MimeMultipart) message.getContent();
mimeMultipart.getCount();
folder.close();
folder.open(Folder.READ_ONLY);
// We have only 19 messages left
System.out.println("NB of elements: " + folder.getMessageCount());
folder.close();
Expected behavior
The email should not be deleted.
Screenshots
Desktop (please complete the following information):
- OS: Mac OS
- Browser NA
- Version NA
Mail server:
- Protocol being used: pop3
- Vendor/product: google
- Mail service URL: gmail.com
Additional context
Add any other context about the problem here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.