Email
7.2 Email
Message transfer agents - Move email across the network.
Source machine establishes TCP socket connection
to port 25
on destination machine.
Sample SMTP conversation delivering an email
from client C to server S.
DCU mail servers
It was easier to see how mail servers worked when DCU had its own mail servers.
But these are being phased out.
Now all DCU email is done through a Gmail service.
Incoming server: imap.gmail.com
Outgoing server: smtp.gmail.com
Of course, these "server" addresses have entire server farms behind them.
If any DCU mail servers still running, try these out:
$ telnet mail.dcu.ie 25
$ telnet mailhost.computing.dcu.ie 25
help
214-2.0.0 This is sendmail version 8.12.10
214-2.0.0 Topics:
214-2.0.0 HELO EHLO MAIL RCPT DATA
214-2.0.0 RSET NOOP QUIT HELP VRFY
214-2.0.0 EXPN VERB ETRN DSN AUTH
214-2.0.0 STARTTLS
Basic email header fields.
Message consists of:
Header fields
(blank line)
Message body
Other email header fields.
Applications can invent their own.
Must begin with X-.
e.g. Some Spam filtering software attaches headers like
X-Spam-Status:
Email headers in forensic work
I receive an unpleasant email from Hotmail.
But where is it actually from? America?
"View - Headers - All" (or something similar) in your email client
and you can see the actual email headers.
These reveal the path it travelled
and also the original IP address, which you can then look up.
Lookup here said it was Eircom, who I then complained to.
I could even see what part of Ireland this came from.
MIME encoding.
Invented for
binary data to be sent by email
(designed for text data).
Encodes it as simple plain text
7-bit ASCII chars.
- Media types
(or MIME types
or Content types)
- IANA
- Not just for email. The Web (HTTP) uses these too.
Types of MIME encodings
base64 encoding:
For binary attachments.
Can encode any binary stream whatsoever as (a really safe subset of)
7-bit ASCII.
"The resultant base64-encoded data has a length that is approximately 33% greater
than the original data"
Content-Type: application/msword; name="Postgrad_Prospectus_Research.doc";
x-mac-type="42494E41"; x-mac-creator="4D535744"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Postgrad_Prospectus_Research.doc"
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAATwAAAAAAAAAA
EAAAUQAAAAEAAAD+////AAAAAE4AAAD/////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////s
pcEATSAJBAAA8BK/AAAAAAAAEAAAAAAABAAAKzIAAA4AYmpiauI94j0AAAAAAAAAAAAAAAAAAAAA
AAAJBBYAIlAAAIBXAACAVwAARywAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAA
AAAAAAD//w8AAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAGwAAAAAAMYBAAAAAAAAxgEAAMYB
AAAAAAAAxgEAAAAAAADGAQAAAAAAAMYBAAAAAAAAxgEAABQAAAAAAAAAAAAAANoBAAAAAAAAshcA
AAAAAACyFwAAAAAAALIXAAAAAAAAshcAABwAAADOFwAAVAAAANoBAAAAAAAAqyQAAIoBAAAuGAAA
....
Quoted-printable encoding:
For basically plaintext with
8-bit ASCII chars.
Encodes everything as 7-bit ASCII.
The 8-bit chars are encoded as:
"=nn".
"=" itself encoded as "=3D".
I have had several enquiries =
regarding=20
IEEE Xplore (full-text access to IEEE and IEE publications) and would =
like to=20
inform you of some recent developments. As part of the<A=20
href=3D"http://www.library.dcu.ie/news/index.htm#HES"> IReL</A> =
initiative (funded=20
by SFI and HEA) to provide increased access to e-journals, negotiations =
for IEEE=20
Xplore are at an advanced stage.
MIME headers.
MIME content types.
How to repair corrupted email
- Sometimes email files can get corrupted or broken.
- If a base64 attachment survives somewhere in the corrupted file, you can extract it as follows:
- Get the raw email file. (View source or view original if you need to.)
- It is plain text so you can just edit it with a text editor.
- Remove everything around the base64 data, including all Header lines (Field: Value) and demarcation lines ("--") and blank lines.
- Then something like:
base64 --decode file > file.jpg
- It works! Decodes it back into the original 0's and 1's.
- You have to know (from surviving Header lines)
what file type the file is meant to be.
Standalone email clients
Email clients - Read and send email.
Mail server: mail.isp.com
receives and stores your email when you are offline.
To read it you might:
- Use a web interface the ISP has set up at: www.isp.com
- Use a standalone client to communicate with
mail.isp.com
over the network,
using various protocols.
Both types of email client
(web clients
and
standalone clients)
are popular.
(a)
mail.isp.com
collects your email.
(b) You periodically use a client to connect to
mail.isp.com
The original protocol for standalone clients.
POP3 client sets up TCP connection to the
mail server
at port 110.
- POP3
- POP3
- Again, possibly try:
$ telnet mail.dcu.ie 110
$ telnet mailhost.computing.dcu.ie 110
- Could write script to loop forever,
alert you when new message comes in from sender X.
Sample POP3 conversation to retrieve 3 email messages.
You can retrieve and then delete from server.
Or retrieve and leave on server.
Updated protocol for standalone clients.
- IMAP
- Multiple clients accessing the same mailbox.
Each sees the others' changes.
- e.g. Access DCU mail from home and from work.
Don't want changes stored on client.
- With POP, can "leave messages on server". But no folders.
With IMAP, can
create mailbox subfolders on the server.
- Other features:
-
Partial fetch. Just fetch header.
Speeds things up.
Do not fetch attachments. Do not fetch body of emails you will never click on.
- Server-side searches.
- Standalone clients can be set up to keep a running mirror on local machine.
As well as writing changes to server.
Web-based email like
Gmail
Keep everything on server (like IMAP).
No standalone client. Just web browser.
Not everyone uses web client only:
- Businesses like security of having local copy of email.
-
For some uses, web client
can be less flexible than standalone client.
e.g. I have programs to "grep" local copy of my email,
programs to build mail rules, etc.
Note that most big web email services can be accessed through either web client
or standalone client.
Gmail supports IMAP access.
Proprietary email protocols
Surveys
Survey of email reading environments, 2018.
From
litmus.com.
Shows the popular ways of reading email:
desktop web browser, desktop standalone client,
and mobile.
Survey of top email clients, 2018.
From
litmus.com.
Shows a mix of
mobile and
desktop
clients.
Huge amount of reading email on Apple devices.
(Is there a problem with data gathering for other devices?)
Also shows a mix of
webmail and
standalone email clients.