To the billions of developers trying to migrate Postfix to a database email solutions:
Q: How does Postfx mark a mail message as "Seen" (the email has been read)?
A: It appends ",S" to the name of the email message file on the file system.
If you just try to parse the postfix mail file into a javax.mail.Message by doing something along the lines of:
MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()), FileUtils.openInputStream(email));
and then try to see if the message was read or not, by calling:
isSet(Flags.Flag.SEEN) will always return false,
since you are not retrieving the message through Postfix.
The way I got around to determining if the message was read or not:
emailFile.getName().endsWith(",S") - true: read; false - NOT read.
Hope this helps someone!
Credit to the best DBA around: Charles Estel aka CJ!