In my ongoing project to bring up my own server (#G), One of my remaining action items has been to bring up a mail server. In this endeavor, I needed to figure out how it worked in order to get it operational, and, in particular, to debug my installation.
Email is ubiquitous on the Internet, probably almost as much as the World Wide Web. We all have email accounts these days. Indeed, you can't do much on the Web without one. Various companies have tried to implement their own proprietary standards, but, for the most part, they have fallen by the way side. Not even Microsoft or IBM has really been able to succeed here.
What is amazing is that the vast bulk of the email today is moved around the world and accessed using the almost original, fairly crude, simple, protocols. The two biggest ones are Simple Mail Transport Protocol (SMNP) and Mail Office Protocol Level 3 (POP3).
The way it works is that your email client (i.e. MSFT Outlook, Netscape, Mozilla, Thunderbird, Eudora) makes a connection with a mail server and utilizes SMNP to send one or more emails to that mail server. The mail server may then establish a connection with another mail server, and send one or more emails to it, again using SMNP protocol. Then, at the far end, your email client makes a connection with a mail server and (typically) utilizes POP3 protocol to query the mail server to see if you have email there in your mailbox, and if so, downloads it to the email client on your own system.
One, two, or more, mail servers may be involved, all communicating via SMNP. I had naively thought that usually there are a number involved. There usually aren't. Usually you have only two. More maybe if you go into or out of a corporate proprietary email system. In the early days, there was a lot of store and forward. But that seems to have gone by the way side, with your local mail server making TCP/IP connections directly with the mail servers of your recipients. I have added a third mail server into the mix by having my local server transmit my email to the mail server of one of my email providers first - but I may just drop that later out, and have it send the mail directly to the recipients' mail servers.
As I noted above, these two protocols are very simple. In the case of SMNP, you have the initiator make a connection. The recipient says HELO. The initiator asks for capabilities, and gets a response from the recipient. In particular, it indicates whether the initiator has to sign on or not. If it is required, then the initiator complies. It then tries to send emails, one at a time, by first specifying the recipient(s). The recipient of the SMNP connection decides, one by one, whether or not to accept that specific email, and if it does, it indicates this to the initiator, which then transmits such. The recipient mail server then acknowledges each email when complete, and the initiator then tries to transmit the next. When done, the initiator signs off. This is all done via a dozen or so short ASCII commands, such as HELO and BYE. POP3 is very similar, except that the direction is reversed and signing on is usually mandatory. Also, a mechanism is included to determine what is in the mailbox for the user and whether to delete the email from his mailbox upon completion of the transmission.
There is a subtlety though in SMNP. You don't always have to sign on to an SMNP server in order to utilize it, and they don't always have to accept each of the emails you try to send it. The way it usually works is that an SMNP mail server will either recognize you or will only take email for certain recipients. The alternative to this are called "open relays", which take email from anyone and relay it to anyone. You usually don't want this, because it is likely that it will be discovered and exploited, resulting in a lot of resource utilization and abetting of nefarious activities.
A couple of more things. A mail server can recognize you either from a log-in (userid/password) or via your computer's (usually TCP/IP) address. If it receives email this way (via SMNP) to one of the mailboxes that it supports (via POP3, Web, etc.), it can bypass spam and possibly virus checks. The other thing is that most mail servers only accept mail from unrecognized initiators of SMNP connections if they are hosting the corresponding mailboxes, but, except for local connections, this involves both an email (mailbox) name and a domain. This is causing me some trouble right now, as I have six or seven domains potentially feeding my mail server, but only expect a dozen or so mailboxes, with, for example, bhayden@domain1, @domain2, etc., all feeding to the same mailbox. Specifying this compactly and concisely is turning out to be a problem.