added the function to send email alerts