Procmail filter for WinKoi conversion

Procmail is the ultimate incoming mail processor. Get and compile latest procmail version first, read the manuals, especially procmailrc(5) and add following lines to your ~/.procmailrc. Please notice that ^I sequences represents real TAB characters, so don't cut&paste this example literally, replace them to the real TABs afterwards. The string "fromwin -b" below is not part of procmail system and means any filter which decode stdin to stdout using windows-1251->koi8-r decode table, I recommend d1489 converter, just follow the link.

 :0 h * ^Content-Type:[ ^I]*text/(plain|html) { :0 fbw * ^Content-Transfer-Encoding:[ ^I]*quoted-printable | mimencode -u -q :0 Afhw | formail -I "Content-Transfer-Encoding: 8bit" :0 fbw * ^Content-Transfer-Encoding:[ ^I]*base64 | mimencode -u -b :0 Afhw | formail -I "Content-Transfer-Encoding: 8bit" } :0 * ^Content-Type:[ ^I]*text/plain([ ^I]*;[ ^I]*charset="?windows-1251"?)?[ ^I]*$ * ^Content-Transfer-Encoding:[ ^I]*[78]bit { :0 fw | fromwin -b :0 Afhw | formail -I "Content-Type: text/plain; charset=koi8-r" } :0 * ^Content-Type:[ ^I]*text/plain[ ^I]*;[ ^I]*charset="?utf-8"? * ^Content-Transfer-Encoding:[ ^I]*[78]bit { :0 fw | iconv -f UTF-8 -t KOI8-R :0 Afhw | formail -I "Content-Type: text/html; charset=koi8-r" } :0 * ^Content-Type:[ ^I]*text/html([ ^I]*;[ ^I]*charset="?windows-1251"?)?[ ^I]*$ * ^Content-Transfer-Encoding:[ ^I]*[78]bit { :0 fw | fromwin -b :0 Afhw | formail -I "Content-Type: text/html; charset=koi8-r" } :0 * ^Content-Type:[ ^I]*text/html[ ^I]*;[ ^I]*charset="?utf-8"? * ^Content-Transfer-Encoding:[ ^I]*[78]bit { :0 fw | iconv -f UTF-8 -t KOI8-R :0 Afhw | formail -I "Content-Type: text/html; charset=koi8-r" }