Can somebody explain the nitty gritty on how email works...

gopunk

Lifer
Jul 7, 2001
29,239
2
0
when a client displays the messages for you, what has gone on? i assume, the client connects with the server, downloads the mail, then displays it, but how does the client connect with the server? is it through tcp/ip sockets? i'm really clueless in this aspect...
 

Crimson

Banned
Oct 11, 1999
3,809
0
0
You want Nitty Gritty? Here you go.. more info than you requested but what the hell...

You send an email to Anand requesting he pay you $1 million dollars or you destroy the Earth.. (Har har)

Your mail program connects via SMTP (Simple Mail Transport Protocol), port 25, to your outgoing mail server (SMTP Server).. Its a plain text connection, basically your email program is a graphical front end to a telnet session.. Your mail server receives the info, and takes a look at the address you are sending it to:

anand@anandtech.com

The SMTP server immediately checks with its DNS server to see if it has an MX (Mail Exchanger) record for anandtech.com... if it does, it forwards the email to the mail server listed as having the highest priority for anandtech.com... If it does not, your DNS server contacts the Authoritative DNS Server for anandtech.com, updates its own info, and forwards the mail to the IP address listed as the highest priority mail server.

Anandtech.com's SMTP server receives the mail from your SMTP server, and usually stores it in a plain text file on the server. Mail files are generally one big text file with headers to tell the mail program where one mail ends and one mail starts..

Anand checks his email.. his mail connection opens a plain text (read unencrypted) telnet session on port 110 of his POP3 server. His mail program pulls his mail file over port 110 to his mail program. The mail program parses the mail file (With the use of headers) into separate messages and displays them all pretty like.

Anand reads your message, and sends you 1 million dollars, thus saving the world..

I could go into more detail but thats basically it.. Yes, its all TCP/IP based.
 

Crimson

Banned
Oct 11, 1999
3,809
0
0
If you are curious, here is a sample header from a recent email of mine.. (Addresses altered to protect the innocent):

----

Return-Path: <johndoe@hotmail.com>
Received: from hotmail.com (f271.law9.hotmail.com [64.4.8.146])
by smtp.domain.net (8.12.1/8.12.1) with ESMTP id
g7QBU1Cc014433
for <joesmith@domain.net>; Mon, 26 Aug 2002 07:30:02 -0400
Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC;
Mon, 26 Aug 2002 05:26:28 -0700
Received: from 204.138.183.29 by lw9fd.law9.hotmail.msn.com with HTTP;
Mon, 26 Aug 2002 12:26:28 GMT
X-Originating-IP: [204.138.183.29]
From: "John Doe" <johndoe@hotmail.com>
To: joesmith@domain.net
Subject: Re: Wassup?
Date: Mon, 26 Aug 2002 05:26:28 -0700
Mime-Version: 1.0
Content-Type: text/html
Message-ID: <F271wcFuTDDzyhXp33m000256fd@hotmail.com>
X-OriginalArrivalTime: 26 Aug 2002 12:26:28.0908 (UTC)
FILETIME=[CD903EC0:01C24CFB]

----

As you can see there is a lot of info contained in that header that your mail program usually supresses. Time stamps, message ID's, encoding types.. originating IP's.. etc..
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
you wouldn't happen to know anything about how a programmer would go about making a connection to an incoming mail server, would you? is imap much different from pop3 in the way this all works?

more specifically, would i use this class?
 

Crimson

Banned
Oct 11, 1999
3,809
0
0
The programing side of it I really don't know very well, but that class does not look like what you need. IMAP is different, but I don't know much about it..
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
Originally posted by: Crimson
The programing side of it I really don't know very well, but that class does not look like what you need. IMAP is different, but I don't know much about it..

ok thanks. i guess i'll have to read up on the imap specifications :)