Adds error checking to mail script