This doesn't appear to be a Courier issue as you've stated the question.
You're using Courier-IMAP to provide access to stored mail after it's
been delivered, but you don't mention using maildrop as your delivery
agent, except in your subject header.
If you were using Maildrop and Courier MTA, you could use the $USER
variable in your maildrop filter rules, which can (on my servers it
always does) contain the full email address of the delivery account. If
you were using SpamAssassin for filtering your email you would want to
store all information (Bayesian filtering info, user prefs,
auto-whitelist info) in a MySQL database as well, and use "-u $USER"
with all relevant SpamAssassin components.
SpamAssassin (probably also dspam and other spam detection programs)
adds headers to email which can be tested and used for mail sorting.
e.g., in my (still experimental) setup: