#286 improvement to mail logic