The ‘Filter Unknown Senders’ feature in iMessage sorts messages from people not in your Contacts into a separate list. It doesn’t block them, but it helps in managing messages from unknown senders.