extractorapp - Improve mail templating system

Same as https://github.com/georchestra/georchestra/pull/804 but rebased onto master.