Implement mailbox endpoint, add DI and simplify the code