質問

Aside from javax.mail.search.SentDateTerm, what's a good way to get the newest message in a particular Movemail folder?

It looks like doveadm is the way to go, although I cannot find a Java driver. However, I'd rather stay within postfix and am not terribly keen on using POP3 (or IMAP), although the integrated Ubuntu stack has alleviated configuration hassles. Any alternatives to javax.mail.search?

The problem I see with javax.mail.search.SentDateTerm is that it requires iterating the folder, which, for large folders, could be problematic. In this case I only want the "newest" message, by sent date.

I'm using Thunderbird to read POP3, but was using a mailutils type folder and want to pop the top message, as if were a stack. Really, just the same thing you seen Thunderbird where the latest message is at the top.

I suppose that it might be feasible to resort to using the file system to sort mail:

root@dur:~# 
root@dur:~# head /var/mail/root 
From root@dur.bounceme.net  Sun Aug 26 00:41:11 2012
Return-Path: <root@dur.bounceme.net>
X-Original-To: root@dur
Delivered-To: root@dur
Received: by dur.bounceme.net (Postfix, from userid 0)
    id AB90A1827DF; Sun, 26 Aug 2012 00:41:11 -0700 (PDT)
To: <thufir@dur>
Cc: <root@dur>
Subject: ping 12:40
X-Mailer: mail (GNU Mailutils 2.2)
root@dur:~# 

Something in Java along those lines to grab the top message? However, that seems fragile and just generally a bad idea, to use the filesystem directly when there may be better options. Perhaps there's some mailutils or postfix hook which Java can take advantage of? An existing API?

One problem with the example command head /var/mail/root is that it grabs the top message, whereas I'm after the top message in a particular folder.

I've switched to dovecot for POP3, but am looking for a good way to interact with the messages which have been popped. This is probably the best approach, but how do you get the top or latest message without iterating the entire folder?

See also: https://stackoverflow.com/questions/12129820/dovecot-doveadm-java-api

役に立ちましたか?

解決

If you really want the newest message by sent date, you have to look at all the messages. If you want the newest message by received date, it's easier - that's the last message in the Inbox.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top