added mail option, moved error to templates