On Mon, 5 Feb 2007, Clive McDowell wrote:
I have a need to remove groups of messages from particular mailboxes based on
blank subject and a To header string. What would the correct mailutil command
for this be? I'm thinking something along the lines of -
mailutil prune "to target subject NULL"
Unfortunately, mailutil won't do that. The search_criteria argument to
"mailutil prune" is an IMAP2 (RFC 1176) format search string which lacks
that capability.
The reason why it's IMAP2 is that that the c-client library has legacy
internal support for IMAP2 search strings built-in. The considerably
more-complex IMAP4rev1 searches are done via a structure called a
SEARCHPGM, and only imapd actually has an IMAP SEARCH criteria specifier.
The legacy routine converts (but modifies) the passed string into a
SEARCHPGM.
You can ignore the rest of this message unless you're willing to do some
hacking. The following information is mostly of interest to hackers and
people who are interested in the arcana of the IMAP protocol.
Even after working around that problem, you have to deal with the issue
that this involves a subtle detail of SEARCH that many IMAP4rev1 servers
get wrong (of course, UW and Cyrus do the right thing). A search for the
empty string always matches; but if the field doesn't exist then the
search always fails.
Hence, in IMAP
tag SEARCH Subject ""
returns all messages that have a Subject header, and
tag SEARCH NOT SUBJECT ""
returns all messages that do not have a Subject header...or rather it does
with a server that follows the rules (such as UW or Cyrus).
However, NOT wasn't in IMAP2 and thus "mailutil prune" won't recognize it.
Now, if what you are looking for are messages which have a Subject but
with empty contents, you have to do some skullduggery. I'd start by
excluding all subjects that have a space, and perhaps also vowels (to try
to exclude single-word subjects), then manually fetch the subjects of what
remains and inspect, e.g., something like:
tag SEARCH SUBJECT "" NOT SUBJECT " " NOT SUBJECT "a" NOT SUBJECT "e" NOT SUBJECT "i" NOT
SUBJECT "o" NOT SUBJECT "u"
tag FETCH .... BODY[HEADER.FIELDS (Subject)]
where .... is replaced by whatever was left from the SEARCH.
And, as noted above, none of this is anything that mailutil can do...
-- Mark --
http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.
_______________________________________________
Imap-uw mailing list
[email protected]
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw