Culprit is midnight commander which sets this strange env variable BASH_FUNC_mc%% I uninstalled mc and kmail works as expected.