Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] POP3, Email is deleted from the server when calling any function on MimeMultipart Object, even when READ_ONLY is set on folder #739

Open
mathias-vandaele opened this issue Sep 27, 2024 · 1 comment
Assignees

Comments

@mathias-vandaele
Copy link

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("[email protected]", "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.

@jbescos jbescos self-assigned this Sep 30, 2024
@jbescos
Copy link
Member

jbescos commented Sep 30, 2024

Could you run it adding this line and copy paste the output, please?.
properties.put("mail.debug", "true");

I am trying it with this example and it is not removing it https://github.com/jbescos/jakartaEE10MailDemo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants