stg mail: factor out __update_header