added state machine and mailer to app