Added error detection in email submission