Find the answer to your Linux question:
Results 1 to 8 of 8
If routing when I send a SMTP mail is handled by the IP layer, and the SMTP server connects directly to the receiver's server, then why do mail messages have ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Mar 2013
    Posts
    169

    Tryong to understand email


    If routing when I send a SMTP mail is handled by the IP layer, and the SMTP server connects directly to the receiver's server, then why do mail messages have headers?

    Which often have long paths, with many hosts along the way?

    Thanks.

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,813
    I believe the email format is covered by RFC-5322 which also has updates - this is the latest in a long line of RFCs that determine what email looks like.

    Email has headers partly for historic reasons - in the old days emails could pass through several servers before landing at their intended target. This is called Relaying, and today is heavily discouraged because it can give emails anonymity, get around spam filters, consume excess bandwidth, and deliver stuff to people who don't want it. But when email is passed on in this way, headers are inserted to show the path the mail has taken.

    They also provide additional useful information about the content of a message - perhaps to define the content type or character set encoding.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Linux Newbie
    Join Date
    Mar 2013
    Posts
    169
    OK, so if relaying IS being used, if I send a mail to say mail@yahoo.com , which hosts MIGHT it go through? How is that decided?

  4. #4
    Just Joined!
    Join Date
    Dec 2009
    Location
    California
    Posts
    98
    Here is an example.
    I am currently reading my email using Thunderbird - a common mail client.
    When I send email to some address like billy@yahoo.com, my mail client is configured to use my mail server (mail.unixpeople.com) as it's relay. The mail is received by mail.unixpeople.com and a received-from header is added (something like... received-from: mylaptop.blah.blah by mail.unixpeople.com at blah, blah).
    My mail server stores that mail in a queue then periodically, it wakes up and tries to deliver it.
    It parses out the domain part of the destination email address (yahoo.com) and then does a DNS query to find the mail exchanger (MX) record for that domain. I just sent this query and the following 3 hosts are returned:
    yahoo.com. 1698 IN MX 1 mta6.am0.yahoodns.net.
    yahoo.com. 1698 IN MX 1 mta5.am0.yahoodns.net.
    yahoo.com. 1698 IN MX 1 mta7.am0.yahoodns.net.

    Now, my mail client attempts to make a connection to mta6.am0.yahoodns.net on port 25... Lets assume that server is too busy to accept the connection. In that case, my mail server will try the next entry (based on the priority listed). Lets assume that mail server accepts the mail.
    Another received-from header is added to the mail.
    Now, internal to yahoo, they may have to deliver the mail to the appropriate server which has billy's mailbox, so that is looked up (possibly in a database or ldap or whatever), and the aol mail server connects to that server and delivers the mail. Another received-from header is added to the email.
    Commonly, that final mail server will deliver the mail to either a single file (mbox format) or to a file in a directory (maildir format).

    When billy fires up his mail client (which is configured to point to the mail server where his mailbox lives), he connects with POP or IMAP to fetch his new email.

    The reason why all those headers are important is for troubleshooting purposes. First, if an email is delayed, I can find out where it was delayed by looking at the time stamps on the received-from headers. Less commonly, if I get a bounce back saying that billy's mail server couldn't be found. I would know the exact path and the server which reported that problem (a lot of time I get bounces from "some" yahoo servers, but not from others.

  5. #5
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    586
    Check out the RFC 2822 https://tools.ietf.org/html/rfc2822 (email spec)
    Last edited by alf55; 01-10-2014 at 01:38 AM.

  6. #6
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,813
    Quote Originally Posted by alf55 View Post
    Check out the RFC 8022 https://tools.ietf.org/html/rfc8022 (email spec)
    Your link doesn't work. Try: https://datatracker.ietf.org/doc/rfc2822/

    But this is now an obsolete document, you need https://datatracker.ietf.org/doc/rfc5322/ and possibly its update document https://datatracker.ietf.org/doc/rfc6854/.
    Linux user #126863 - see http://linuxcounter.net/

  7. #7
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    586
    The last time I looked at 5322, it was not yet in "Draft Standard". But that was probably nearly two years ago. Sorry for the "bad link", I had an out of date bookmark.

  8. #8
    Linux Newbie
    Join Date
    Mar 2013
    Posts
    169
    Hey I just read abarclays comment, I had saved it to read for later. Thanks so much, it's now clear.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •