Spam is annoying, but there are some steps you can take to stop seeing spam related messages!
This support page goes into how to detect and block unknown callers: Detect and block spam phone calls - Apple Support.
For Messages:
- Open Settings on iPhone
- Scroll down and tap on Messages
- Scroll down (near the end) and toggle "Filter Unknown Senders" on.
Your Messages app will look a little different when opening it, but you can now filter by All Messages, Known Senders, and Unknown Senders. You'll want to select Known Senders. To Filter, please click on "< Filters" in the upper left corner and select which option you'd want.
Mail will be a little more challenging, however, possible. If you're receiving constant spam that is similar in nature, most if not all Mail providers allow you to create inbox rules.
The easiest way to setup Mail rules will be from https://www.icloud.com/mail/ or using the Mail app on macOS.
macOS: Use rules to manage emails you receive in Mail on Mac - Apple Support
Safari: Set up rules to filter email in Mail on iCloud.com - Apple Support
Spam emails are annoying and part of the reason is online websites and companies selling your personal information (including your email). Your email could also be leaked when one of these companies is infiltrated. It's definitely worth the price to upgrade to iCloud+ and utilize Hide My Email. Hide My Email allows you to generate fake emails to use instead of giving them your real, personal, email. Tired of Spam? Deactivate that email address. You can learn more about Hide My Email here: What is Hide My Email? - Apple Support.