finished the emai functions