add error/disconnect handlers to mail plugin