A sending mail server looks up the MX record of the recipient domain and delivers to the host listed there. Every MX has a preference value: the lowest is tried first, higher values act as fallback.
The MX must point to a hostname with an A or AAAA record, never to an IP address or a CNAME. A backup MX that accepts mail without knowing the valid recipients quickly turns into a backscatter source.
Typical mistake when switching providers: the old MX stays in the zone with the same priority, and part of the mail keeps landing in the old mailbox.
Example
dig +short MX example.com