0

I've recently configured new .procmailrc and .forward files to work with our Postfix mail server. I've tested it with new Emails, and the new .procmailrc is properly filtering and forwarding as desired.

Now I would like to somehow re-process the entire contents of my /var/spool/mail/***username*** file using the new .procmailrc so that all 2000+ messages will be properly sorted into my new ~/mail/Likely-Spam, ~/mail/Almost-Certainly-Spam, ~/mail/Cron-Jobs, ~/mail/Email-Backup, etc..., and forward all non-filtered messages to my company outlook account... for posterity.

Is there a straightforward command to accomplish this?

My mail server is running RHEL 7 with postfix.

1 Answer 1

1

procmail comes with another program called formail which can be used to process an existing mbox. You can use that to pipe your mailbox back into procmail.

To avoid race-conditions with newly arriving mail, I'd rename the spool mbox before processing it. For example:

mv /var/spool/mail/username /var/spool/mail/username.orig
formail -s procmail < /var/spool/mail/username.orig
rm /var/spool/mail/username.orig

any arguments and options after -s procmail will be passed on to procmail.

From the formail man page:

-s

The input will be split up into separate mail messages, and piped into a program one by one (a new program is started for every part).

-s has to be the last option specified, the first argument following it is expected to be the name of a program, any other arguments will be passed along to it.

If you omit the program, then formail will simply concatenate the split mails on stdout again.

see man formail and man procmail for more details.

1
  • Thank you cas. I was forced to stay home from work today to care for my wife. I'll work on this, and let you know soon. Commented Oct 23, 2019 at 19:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.