Firewalls work by establishing a set of rules that determine which traffic is allowed or denied access to your network. These rules can be based on IP addresses, domain names, protocols, ports, and other criteria. When an email arrives at your server, the firewall scrutinizes it against these rules to decide whether to permit or block it. This process helps in filtering out spam, phishing attempts, and other malicious content.