Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Office 365 mail Inbox folder EXPUNGE failed with IMAP using java mail API

I am connecting Office 365 mailbox using java mail API with IMAP protocol.

We have continuous stream of messages to mailbox and reading those through java mail API. Once messages are read, those will be moved to other folder or deleted. After successful move/delete of a batch I am doing expunge on INBOX folder.

The above functionality is doing good for around 72 hours and then EXPUNGE command is continuously failing. Following is the exception observed

javax.mail.MessagingException: A447 NO EXPUNGE failed.; nested exception is: com.sun.mail.iap.CommandFailedException: A447 NO EXPUNGE failed. at com.sun.mail.imap.IMAPFolder.expunge(IMAPFolder.java:2190) at com.sun.mail.imap.IMAPFolder.expunge(IMAPFolder.java:2151) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.mail.IncidentsMailboxReader.expungeConnectionInbox(IncidentsMailboxReader.java:423) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.mail.IncidentsMailboxReader.updateCompletedConnection(IncidentsMailboxReader.java:311) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.mail.IncidentsMailboxReader.checkAndUpdateConnectionInstances(IncidentsMailboxReader.java:285) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.mail.IncidentsMailboxReader.getUnreadIncidentMails(IncidentsMailboxReader.java:76) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.worker.IncidentMailsProcessor.findAndProcessUnreadMails(IncidentMailsProcessor.java:200) at com.eiq.socvueportal.securitymonitoring.incidents.feeder.worker.IncidentMailsProcessor.run(IncidentMailsProcessor.java:85) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: com.sun.mail.iap.CommandFailedException: A447 NO EXPUNGE failed. at com.sun.mail.iap.Protocol.handleResult(Protocol.java:399) at com.sun.mail.iap.Protocol.simpleCommand(Protocol.java:425) at com.sun.mail.imap.protocol.IMAPProtocol.expunge(IMAPProtocol.java:1479) at com.sun.mail.imap.IMAPFolder.expunge(IMAPFolder.java:2183) ... 10 more

How can this be avoided? And at what scenarios this can be observed?

like image 704
Mallikarjun B Avatar asked Aug 04 '17 09:08

Mallikarjun B


1 Answers

The server is failing the expunge request. Contact Microsoft to find out why the server is failing. As a workaround you can close the folder and reopen it; the expunge will be done when you close the folder.

like image 109
Bill Shannon Avatar answered Sep 28 '22 23:09

Bill Shannon