Mail State Machine refactor. Closes: #4059
changes file