Backend code for message inbox