impelemted the sending email feature and extract the username from CAS