Added email function to the code