added email sending functionality