idfile variable not being picked up in template due to scope issues.
add mail-format support
Merge pull request #29 from meltwater/master

idfile fixup, add mail-format support