pentaho/pentaho-kettle · error · KettleException
MailConnection.Error.DeletingMessage
Error message
MailConnection.Error.DeletingMessage
What it means
MailConnection.deleteMessage() wraps any exception raised while flagging the current javax.mail Message with Flags.Flag.DELETED into a KettleException with message key MailConnection.Error.DeletingMessage, including the effective message number. It is thrown when the underlying mail store (IMAP/POP/MBOX) refuses or fails the delete operation. The original cause is attached, so the JavaMail exception is the real diagnostic.
Solutions
- Open the IMAP folder in READ_WRITE mode before deleting messages (folder.open(Folder.READ_WRITE)).
- Read the wrapped cause 'e' in the KettleException to identify the underlying JavaMail failure.
- Re-fetch the message list if the message was expunged, then retry the delete.
- For MBOX protocol, verify the mbox file and its parent directory are writable by the Pentaho process user.
Example fix
// before
connection.setPopupFolder("INBOX");
connection.fetchNext();
connection.deleteMessage(); // fails: folder read-only
// after
connection.setPopupFolder("INBOX");
// ensure the folder was opened READ_WRITE by MailConnection before fetching
connection.fetchNext();
try {
connection.deleteMessage();
} catch (KettleException e) {
logError("Delete failed for message: " + e.getMessage(), e);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (folder.getMode() != Folder.READ_WRITE) { throw new IllegalStateException("Folder must be opened READ_WRITE to delete messages"); } Type guard
if (connection.getMessage() == null) return false; // no current message to delete
Try / catch
try { connection.deleteMessage(); } catch (KettleException e) { logError("Delete failed: " + e.getCause(), e); } Prevention
- Always open IMAP folders READ_WRITE when deletes are planned
- Check the folder supports Flags.Flag.DELETED for the protocol
- Handle expunged messages by refreshing the message list before retries
When it happens
Trigger: Calling MailConnection.deleteMessage() after fetchNext() when message.setFlag(Flags.Flag.DELETED, true) throws — e.g. folder not open READ_WRITE, the message was expunged server-side, or the MBOX file is not writable.
Common situations: IMAP folder opened read-only so the DELETED flag is rejected; POP3 servers that do not support server-side flags; the message was already deleted by another client; permissions problems writing the MBOX file.
Related errors
- JobGetMailsFromPOP.Error.ClosingFolder
- JobGetMailsFromPOP.Error.OpeningDefaultFolder
- JobGetMailsFromPOP.InvalidDefaultFolder.Label
- JobGetMailsFromPOP.InvalidFolder.Label
- MailConnection.DefaultFolderCanNotHoldMessage
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/75874b28988b2f6a.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/email-messages/impl/src/main/java/org/pentaho/di/job/entries/getpop/MailConnection.java:1078
retval = ( matcher.matches() );
}
return retval;
}
/**
* Delete current fetched message
*
* @throws KettleException
*/
public void deleteMessage() throws KettleException {
try {
this.message.setFlag( Flags.Flag.DELETED, true );
updateDeletedMessagesCounter();
if ( this.protocol == MailConnectionMeta.PROTOCOL_MBOX ) {
this.messages = this.mboxMessages;
}
} catch ( Exception e ) {
throw new KettleException( BaseMessages.getString( PKG, "MailConnection.Error.DeletingMessage", ""
+ getEffectiveMessageNumber( getMessage() ) ), e );
}
}
/**
* Set destination folder
*
* @param foldername
* destination foldername
* @param createFolder
* flag create folder if needed
* @throws KettleException
*/
public void setDestinationFolder( String foldername, boolean createFolder ) throws KettleException {
try {
if ( this.protocol == MailConnectionMeta.PROTOCOL_MBOX ) {
this.destinationMboxPath = prepareMboxDestinationPath( foldername, createFolder );
return;View on GitHub (pinned to f3058517a1)