removing send_mail functionality
adding send_mail on error
moving send_mail funciton back to this file
moving error alert to this function