The basic transfer system is SMTP (Simple Mail Transfer Protocol).
That is very simply a plain-text telnet connection to Port 25 on a machine that has an email server running. There are a few very simple commands to send the 'from' address, 'to' address, them message header & body.
If someone sends email via an email program on a computer, that transfers it to the SMTP server listed in their email settings (ie. usually their ISPs email system).
With webmail, that generally puts the message straight on a local server.
The initial email server does a DNS lookup on the domain part of the 'to' address in the message (the part after the @).
It will get back an MX record with the IP address of the mail server handling mail for that domain.
It then forwards the message to the destination server, again using SMTP.
At any stage of the process, a server can reject a message if it tries a DNS lookup on the domain part of the address and cannot find any mail server record for that domain - if the domain does not exist, eg. due to a typo in the email address, the message will be bounced back to the sender.
When it's delivered to the final server that is responsible for the @domain, the first part of the email address will be checked against known accounts on that server.
If the account exists, the message will be stored in that users 'mailbox' - depending on the particular server, that will be a folder for the account containing a file for each message, or a single file for each account with each new message added on the end.
If there is no matching account, the message gets returned to the sender.
When someone checks for mail, the email program (or web site) logs in to their account using either POP3 or IMAP.
POP3 is again a simple plain-text telnet protocol, to Port 110.
The mail program asks for a list of stored messages, and if there are any new ones it can retrieve them and store them locally or display them.
The complex parts of email come in when it has to handle images or binary files - the basic SMTP system is decades old and was only designed for basic text use; it cannot handle binary data.
Email programs have to re-code any images or binary attachments using 'base 64' coding, which converts each three bytes of data to four 'readable' (but garbage) characters.
If you ever look at the page source for an email containing an image or HTML content, you will typically see a header line referring to MIME format then a table of what looks like random junk text. That is the actual message stored in base 64 for transfer via SMTP.
See the links.