Added flag handling and basic email format generation