So we know how fairynet talks to dragonnet to send a message. But How does fairynet know where to send the message too?
fairynet has to lookup where dragonnet is, and it does this by asking the Domain Name System (DNS for short) where dragonnet emails get delivered, this is a special type of DNS record called a Mail eXchange (or MX) record. dragonnet may not accept it’s emails directly. It may have another system accept it’s messages, to protect it from malicious actors, or from junk messages, or simply because it’s too small to handle the load of dealing with lots of separate connections for accepting messages.
So fairynet finds out the dragonnet emails need to be sent to mailfilternet from the DNS MX records, and gets an address for mailfilternet.
Now fairynet will still have the same conversation as we lined out on the last page, but it has it now with mailfilternet, and mailfilternet will have been told where it needs to find dragonnet to deliver the messages onward, and so now mailfilternet will go through the conversation with dragonnet itself.
The programs that handle these conversations are known as Mail Transfer Agents (MTA’s) and they all follow this pattern. If they have been told of a host that takes email for a certain domain they’ll send it on to that host, otherwise they’ll look for the DNS MX records for that domain. In reality there could be lots of transfers from one host to another before a message is finally delivered.