Added working emailing function