error handling and smtp fixes