inbound_email: split recipient matching logic out
This allows calling the function on a single recipient rather than on a whole message, when one isn't available.
Depends on !777 (closed)
Test Plan
Some simple tests have been added.
Migrated from D7498 (view on Phabricator)