add attachment to mail, testing mail, refactoring, add pattern check