I once wrote a quick proof of concept: https://github.com/FriendsOfFlarum/mailbox
The idea behind mailbox is that you configure IMAP credentials for a tag (primary or sub/childtag) which then gets seeded all email from that IMAP box. Senders are matched to existing users or added on the fly. When replying inside the discussion an email is send to the original author of the email from the mail address configured as SMTP.
Here's the WIP discussion: https://discuss.flarum.org/d/22855-wip-extension-mailbox
I have plans to finish it, but it's not a priority right now.