finalized mail function v.01