iOS users have a similar feature that acts as a spam filter. To enable it, follow these steps:
Open Settings
Tap on Messages
Scroll down and turn on the Filter Unknown Senders option
This method will create a separate Unknown Senders tab in your default messaging app. If the sender is not in your address book, their messages will end up there and won't trigger a notification.
Be careful not to lose important messages from unsaved numbers (for example, when you order food delivery).
https://donotpay.com/learn/spam-texts-from-email-addresses/