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
#739 1 comment 4 reactions 1 assignee View on GitHub

@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

image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.