Mail Server

Email as we understand it now started on single mainframe computers in the mid-1960s.  At that time computers were not linked to each other and users used dumb terminals to run applications on the mainframe.   The first email applications were really simple local file sharing, where users deposited text messages in an email folder owned by the recipient.  Early mail programs were SNDMSG and MAILBOX.

Email was therefore limited to users on the same computer.  We waited for the development of local and remote networking and interconnection of computers before the next big step. 
As with so many developments, the net big step came courtesy of the military.  The US Government were running a major military networking development program, ARPANET, which later morphed into the Internet as we see it now.  

Networking computers meant the mail problem became a little more complex - a message needed to go into an envelope, addressed and sent.  The recipient need not be on the same computer anymore.  So, the first matter was to locate and uniquely identify the recipient as with paper mail (now becoming known as snail mail).  ARPANET and Ray Tomlinson fixed that.  Ray Tomlinson defined email addresses to be user@computer.  Something we still use today.  With this "nice hack" as Jan Postel described it, we were good to go with a massive expansion of networked email. 

The first universal email systems were based on the existing paper mail systems and were in effect a store-and-forward system using the Post Office Protocol3 ("POP3") and Simple Mail Transfer Protocol ("SMTP") standards.   The computers storing the mail are known as mail servers. 

Using the Tomlinson address structure, networking software would use SMTP software to forward the message to the mail server where the POP3 software would receive the message for the recipient.  The steps in between were handled by standard networking techniques. That ability was dependent on the development of the Internet to be able to route the email to its ultimate destination. 
To get a little bit technical:

Mail Routing Procedures
The Internet is designed around the Internet Protocol (“IP”).  Every device connected to the Internet has a unique IP address of 12 numbers. This makes the @computer part of the email address possible.  
The 12 numbers are usually broken up into 4 groups of three digits each.  The groups define the network location of the machine and identify the individual machine within that network.  
A postal address is made up of a country part, a city part, a street part, then a house number part. All people living in your area will have the same country and city parts. Only the house number and street parts will be different.  A machine on a network will have the same first two groups of numbers, (the country and city bits), perhaps the same third group (street bit), but definitely, a fourth bit (house number) that makes it unique. 
The next thing is to relate the numerical IP addresses to addresses that we understand.  It is much easier to remember widgets.com than something like 104.25.18.32.  This is achieved through Domain Name Servers (“DNS”), servers which hold a table of relationships between IP addresses and names.
Finally, the first three digits usually denote a country or continent.  For example, IP addresses starting 081 are European addresses, 041 are African addresses.
The routing process is therefore for your email to be routed to the main mail exchange server in the country or continent, from where it is forwarded to the local mail exchange for the city and finally to your own mail server.   Exactly the same as the method used to deliver paper mail. 

Mail Server Protocols
POP3 and SMTP.
When an email arrives at a mail server, it is processed using the POP3 protocol and placed in the user’s mailbox according to the user part of the user@computer address.   If the address is invalid or the box is full, a return message is sent to the sender.  Some email servers allow the user to automatically pre-process an e-mail for example by moving it to a junk folder, forwarding it to another address, or sending a Holiday message back to the sender.
POP3 mail needs to be downloaded from your mail server to your local computer, and SMTP mail to be sent needs to be uploaded for onward transmission.  The POP3 service downloads email automatically or on request to the user desktop email client.   The client logs onto the POP3 server using an id/password combination and initiates the download.  Various types of connection are specified allowing for different levels of security.  Most clients have add-on software to process higher levels of security, for example, PGP. 

The SMTP service simply delivers outgoing mail to the email server and requests for it to be sent.  It has little security and the biggest complaint about it is that if a hacker knows your SMTP id/password combination, they can use it to send large volumes of spam emails.
IMAP
IMAP allows you to reach your email messages wherever you are and from different machines, usually via the Internet. When you check your inbox, your email client contacts the server and connects you using the IMAP protocols.   Your email client then displays the headers of all your emails on the server. 
If you decide to read a message, it is quickly downloaded to your desktop - emails are not downloaded unless you need to open them.  This allows offline access to downloaded messages only.  Similarly, attachments are only downloaded on request. 
IMAP can also send and retain messages.  If you do work offline, IMAP synchronizes your offline and server mailboxes.
IMAP is a much better protocol for mobile users who want to use their email from a variety of devices. 
Internet Mail
The latest development is cloud-based email, where the email stays on the Internet.  Prime examples are Windows Hotmail, Google Gmail, and other branded online mail services provided by commercial organizations and Internet Service Providers.    Users have access to the same facilities as with offline email clients.
Like IMAP, this gives access to email from a variety of devices including smartphones and tablets.  Cloud based mail services are usually bundled with other applications like calendar and messaging services.  

Email Server Software