mail funtion update