Friday, 1 October 2010

Understanding SMTP and mail delivery

A couple of IT guys new to the business have recently enquired to the workings of SMTP. Below I attempt to explain the basics of how mail is delivered and accepted.

SMTP stands for 'Simple Message Transfer Protocol' and in itself is a very basic text form of message transfer. A straight forward set up would comprise of a server running mail software listening on port 25 for connections waiting for a sending mail server to connect to it. A listening mail server will be configured with a list of domain names in which it can accept email delivery. So for this example we'll use xyz.com.

When a sending server connects to the 'listener' on port 25 a few text based transactions take place. Mainly, the identity of the sending mail server - i.e. abc.com and the intended recipient of the email - for example fred@xyz.com. As long as the domain matches an approved list, the receiving server will accept delivery of the email, match the message to a user list and then either pass on the message or bounce it back to the sender (usually be making an outbound SMTP connection back to the sending server and generating a bounce message).

In order to receive an email the sending server must know how to reach it so here goes a basic explanation of DNS and MX records..

DNS servers are like an index which is searched upon to tell the requester the location of a server/service. We'll just focus on A and MX records for now.

Firstly, a server needs a name - mail.xyz.com will do for now. So, say the server listening for xyz.com's email has an internet IP address of 111.111.111.111 there would be an A record pointing to this.

It would look like

mail.xyz.com.   A   111.111.111.111

It's as simple as that. But for mail transfer to work there also needs to be a 'mail exchange' record for xyz.com to explain where to send the email. We know it needs to go to mail.xyz.com so...


MX 5 mail.xyz.com.


Would be a typical entry that you would need. This tells the sending server that any mail for xyz.com is sent to mail.xyz.com which is based at the IP address of 111.111.111.111. The sending server than creates a connection on port 25 to 111.111.111.111 then transacts the email across.

All in all, this is a very basic, plain email system. There are many variables and security aspects and spam implications. As you can see, an SMTP receiver by itself just 'listens' for email. A bit like a postbox is ready to receive a letter from ANY sender. Without more advanced configuration a high risk of spam and the possibility of configuring an open relay is always a risk. We'll explain this in more detail soon.

1 comment:

Unknown said...

Thanks for that Mark much appreiciated. It does help the understanding of emails and how they work. Also this made my brain trigger and stopped me asking you another questions as it was covered in this entry.

Regards

Josh Davis
Paragon Skills for Industry