Refactor mailing and only send mails in debug to whitelisted users