Use this script.

In the aliases file put entry like this:
spam: spam@spam.spam
nospam: nospam@ham.ham

Then in transport file specify a transport for these:
spam.spam sa-spam:
ham.ham sa-ham:
Then in the master.cf make the following addition (this will feed the coming mail incoming mail as input to the sa-wrapper.pl )
sa-spam unix - n n - - pipe user=mail:mail argv=/usr/local/bin/sa-wrapper.pl spam ${sender}

sa-ham unix - n n - - pipe user=mail:mail argv=/usr/local/bin/sa-wrapper.pl ham ${sender}

Then for mutt:
macro index S ":set autoedit=no fast_reply=yes editor='/bin/true'\nspam@[MYNETWORK]\ryd :set autoedit=yes fast_reply=no editor='/usr/bin/vi'\nq"

macro index H ":set autoedit=no fast_reply=yes editor='/bin/true'\nham@[MYNETWORK]\ryd :set autoedit=yes fast_reply=no editor='/usr/bin/vi'\nq"