fixed email sending logic, now it catches more exceptions