Added email logging for errors
Added configuration support