On 2005-08-17 11:58, Matt Juszczak <[EMAIL PROTECTED]> wrote: > I know how to: > > 1) recursively pull each Spam folder in existance (for x in `ls > /home/*/mail/Spam`; do ....; done) > 2) Use grep and awk to pull each message and its relative data (grep the > date, parse it) > > What I'm not sure of is how to remove a message from the spool itself. > Should I just use grep and/or sed to "pull until new From header", then > remove those lines from the spool manually? > > This would be easier if I could use IMAP, because then I could use the > built-in PHP functions for imap to check dates and remove messages. > Problem is, we don't know the user's passwords (they are hashed). > > Any other ideas? Thanks!
For a similar purpose (removing duplicates from a UNIX mailbox file), I use a temporary procmailrc ruleset with the -D option of formail(1) and save some of the messages of the original mailbox in a temporary file. You can do something similar, but use a properly crafted procmailrc that saves only "new enough" messages. The script I use to remove duplicates from mailboxes is: % #!/bin/sh % % if [ $# -eq 0 ]; then % echo "usage: $(basename $0) file [...]" >&2 % exit 1 % fi % % TMPDIR="${TMPDIR:-/tmp}" % export TMPDIR % % for fname in "$@" ;do % mbox=$(mktemp "${TMPDIR}/$(basename ${fname})-XXXXXX") % filter=$(mktemp "${TMPDIR}/procmailrc-XXXXXX") % msgid=$(mktemp "${TMPDIR}/msgid-XXXXXX") % % if [ X"${mbox}" = X"" ] || [ X"${filter}" = X"" ] || \ % [ X"${msgid}" = X"" ]; then % echo "$(basename $0): error: failed to create temp files." >&2 % exit 1 % fi % % echo "DEFAULT=${mbox}" > "${filter}" && \ % formail -D 32768 "${msgid}" \ % -s procmail "${filter}" < "${fname}" % if [ $? -eq 0 ] && [ -f "${mbox}" ]; then % mv "${mbox}" "${fname}" % echo "ok ${fname}" % fi % /bin/rm -f "${filter}" "${msgid}" % done You can write a similar script to filter any mailbox through any procmail ruleset, as long as you have tested the ruleset and found that it works exactly like you want it to work. - Giorgos _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"