How email works

themagiconethemagicone Member Posts: 674
Can anyone give me a sorrta in-depth quick review of how email works? I understand the basics - you send mail on port 25, receive on 110. Then I know the MX records point to the server. But that is where my understanding breaks down. If I have my domain hosted at a random web hosting service but I want to run a email server at my house using the same domain, can I? Do I just change the MX records to point to my IP?

When I send mail currently I send it to my current host and from there it goes out. If I host it in my house I'll connect locally to the server but where does the server send it?


Just curious how it all works on the back end. Thanks
Courses Completed at WGU: JIT2, LYT2, TFT2, SJT2, BFC2, TGT2, FXT2
Courses Required For Me To Graduate WGU in MS: IT Network Managment: MCT2, LZT2, MBT1, MDT2, MNT2
CU Done this term: 16 Total CU Done: 19
Currently working on: Nothing Graduation Goal: 5/2013

Comments

  • WebmasterWebmaster Admin Posts: 10,292 Admin
    When I send mail currently I send it to my current host and from there it goes out. If I host it in my house I'll connect locally to the server but where does the server send it?
    To the Mail eXhanger (MX) for the target domain. So your mail server would perform a DNS lookup to find the MX record for the domain in the recipient's email address.
    If I have my domain hosted at a random web hosting service but I want to run a email server at my house using the same domain, can I? Do I just change the MX records to point to my IP?
    Yes that's basically the purpose of the MX record, to point to the host that is responsible for receiving the mail for a particular domain.
    you send mail on port 25, receive on 110.
    That's the classic situation for client-server communication yes. The actual ports used depend on the protocol being used however, in this case 25 is SMTP and 110 POP3. For server-to-server communication SMTP is used (also for receiving to confuse things a bit).
  • themagiconethemagicone Member Posts: 674
    So what happens when your ISP blocks port 25? I currently use port 580 something to send via my hosted mail server.
    Courses Completed at WGU: JIT2, LYT2, TFT2, SJT2, BFC2, TGT2, FXT2
    Courses Required For Me To Graduate WGU in MS: IT Network Managment: MCT2, LZT2, MBT1, MDT2, MNT2
    CU Done this term: 16 Total CU Done: 19
    Currently working on: Nothing Graduation Goal: 5/2013
  • instant000instant000 Member Posts: 1,745
    So what happens when your ISP blocks port 25? I currently use port 580 something to send via my hosted mail server.

    Port 25 is a well-known port. (Which means most mail systems trying to send you mail are going to send it to you on port 25).

    Technically, you can configure your mail to work on any of a wide number of ports.

    However, if 25 inbound is indeed blocked, you might have issues in receiving mail from others, a workaround in this case would probably be a smarthosting setup, where your mx record is hosted at your provider (and every other person you work with can hit that on 25), then it forwards to you, on the port that you prefer, which would be 580, in this case.

    most people use some type of smart hosting setup, as it prevents someone getting directly to your actual mail server, just be careful in your DNS records setup, but your hosting provider should be able to square you away on this.

    then, you just set your firewall, for this particular smart host IP/port combo to hit your mail server, which gives you a little more security.

    Hope this helps.

    Of course, the standard disclaimer is that this is not a fully-featured security solution, and a security solution is only as robust as the defender who is constantly looking for weaknesses in their defensive setups, and strengthening them.

    while looking into this issue for you, I see a provider who brags on their ability to bypass the port 25 setup (by doing a smarthosting setup, as I'd already outlined above)

    Blocked Port 25? .. Mail on a Non-Standard Port

    DISCLAIMER: This is free advice on this wonderful thing we call the internet, no guarantees of security or performance of any kind.
    Currently Working: CCIE R&S
    LinkedIn: http://www.linkedin.com/in/lewislampkin (Please connect: Just say you're from TechExams.Net!)
  • Forsaken_GAForsaken_GA Member Posts: 4,024
    It's usually not worth it to run a mailserver at home on a residential connection. Port 25 blocks mean you need a smarthost outside of the ISP in order to relay mail to your internal home server, and if you're going to do that, you might as well just run the mail server on that box as well.

    If you care about your email, I wouldn't recommend running it at home. Your uptime will not be 100%, whether through power outages, or internet outages, you risk losing some mail. If you don't care about your mail, then this is a non-issue. I personally rent a small VPS, and host my mail server on that.

    If your ISP doesn't block port 25, you may still run into some issues. The major ISP's have their DHCP ranges in alot of blacklists, so if you try to send mail to a server that does subscribe to one, your mail is going to be refused. If you absolutely positively must run a mail server at home, pop for a business class connection. Those IP ranges are not typically on blacklists, and they don't typically block any ports.

    As for how it all works - your mail client is set to a specific SMTP server. When you compose, your client sends the mail to that server. That server will either then relay it to another pre-configured server, in the case of a smarthost, or look up the MX record for the destination domain, and then send directly to that server. Unfortunately MX records do not allow you to specify port numbers, so any mail that's sent via MX lookup is going over port 25.

    Once the remote mail server accepts the message, it gets delivered to the users mailbox through whatever means they provide on the backend (and there are many). If someone replies to that email, the process reverses. When the remote mail server sends to the mail server defined in your domains MX record, your mail server accepts the message, and then delivers the message through whatever means you've provided on the backend (again, there are many - maildrop, procmail, dovecot, exchange, whatever, far too many to detail in a generalized post like this), and the backend eventually drops it into your mailbox. Your mail client then connects to whatever mail server is holding the mail (whether it's POP3/S or IMAP/S - servers which hold the mail are typically referred to as the MDA, Mail Delivery Agent, while the SMTP server is typically referred to as the MTA, the Mail Transfer Agent, to give these specific concepts names) and then allows you to view it with your mail client (typically called an MUA, Mail User Agent!)

    The mail flow isn't all that complicated, and the protocols are pretty simple. It's not until you try to start doing stuff like filtering that email gets complicated.
  • EveryoneEveryone Member Posts: 1,661
    It's usually not worth it to run a mailserver at home on a residential connection. Port 25 blocks mean you need a smarthost outside of the ISP in order to relay mail to your internal home server, and if you're going to do that, you might as well just run the mail server on that box as well.

    If you care about your email, I wouldn't recommend running it at home. Your uptime will not be 100%, whether through power outages, or internet outages, you risk losing some mail. If you don't care about your mail, then this is a non-issue. I personally rent a small VPS, and host my mail server on that.
    ^^ This.

    I setup a Zimbra server at home, just because I wanted to play around with it. I have the same domain name in .com, .net. and .org. The only one I really use is the .com, and that is my main e-mail address, so I leave that one on a hosted service. I decided to use the .net for testing/playing around with things at home. I would suggest doing something similar. Only use your home network for a test environment.

    On a semi-related note, I have considered switching to business class services, as well as getting a good UPS and back-up generator. My cable company offers a business class service with the same speeds as my residential service for about the same price. Difference is the business class is not limited like the residential is, and doesn't have port blocks. I can also get a block of 5 static IP's for an extra $20/month.
  • themagiconethemagicone Member Posts: 674
    Thanks. I was just planning on playing around with a test server I have, setting up email/web/etc. Just trying to have a better understanding of how things work together.
    Courses Completed at WGU: JIT2, LYT2, TFT2, SJT2, BFC2, TGT2, FXT2
    Courses Required For Me To Graduate WGU in MS: IT Network Managment: MCT2, LZT2, MBT1, MDT2, MNT2
    CU Done this term: 16 Total CU Done: 19
    Currently working on: Nothing Graduation Goal: 5/2013
  • it_consultantit_consultant Member Posts: 1,903
    Can anyone give me a sorrta in-depth quick review of how email works? I understand the basics - you send mail on port 25, receive on 110. Then I know the MX records point to the server. But that is where my understanding breaks down. If I have my domain hosted at a random web hosting service but I want to run a email server at my house using the same domain, can I? Do I just change the MX records to point to my IP?

    When I send mail currently I send it to my current host and from there it goes out. If I host it in my house I'll connect locally to the server but where does the server send it?


    Just curious how it all works on the back end. Thanks

    Magic. icon_smile.gif OK, kidding.

    You have to think in terms of components, people who came up in Exchange (me) are bad at this, those who set up Linux email servers know it better. Client side SMTP sends and POP receives. Server side everything is SMTP because to them sending and receiving is almost the same thing. If you set up a simple IIS SMTP server the service needed to send and receive email is the SMTP service. In order to RETRIEVE the mail you need POPIII or IMAP4. A server never initiates a POP or IMAP connection, only clients do that. SMTP can be initiated by a client or a server depending on the circumstance.

    The problem with exchange pre 2007 is that all of this was jammed into one box: routing, sending, receiving, and retrieving.

    Client access: responds to clients over POP, IMAP, and MAPI

    Hub Transport: routes and sends/receives mail - this is still a little garbled. Hub Transport looks up MX records, it also opens connections to a recipient email server to deliver mail. It also receives incoming SMTP requests

    Mailbox Server: houses all your data

    Edge transport: this server ONLY initiates and receives SMTP connections.

    Have I enlightened you or confused you further? In a hosted set up all you do is initiate SMTP and POP sessions with a remote server. All the MX lookups and sending and receiving happens on the remote host. The remote host is where the MX record points.
  • phoeneousphoeneous Go ping yourself... Member Posts: 2,333 ■■■■■■■□□□
    Thanks. I was just planning on playing around with a test server I have, setting up email/web/etc. Just trying to have a better understanding of how things work together.

    You can sorta still do that with a virtual lab.
Sign In or Register to comment.