As far as purchasing a domain goes, lets remove the 'purchasing' part for now and just talk about the having a domain. To recieve email, you will of course need an email address. Also, you will have to have a domain and a mail server that is registered for that domain. Here is an overview of how the senders SMTP server gets email to your SMTP mail server.
*Reads in email from it's 'Send" folder
*Performs various checks, most importantly it checks the "To" address of the email.
*Breaks the email address up into two parts - mailbox name and domain name
*Queries DNS for the IP address of the authoritative mail exchanger ( aka "mx record", aka "SMTP Gateway" ) for that domain.
*Contacts the mail exchanger and attempts to deliver the email.
So you see it uses the domain name to figure out where to deliver the email to, making it important to have a domain. I have done domains a few different ways in the past, but currently I have two domains registered and pointing at my home network. One is free, and one I purchased. Both are hosted at
http://www.dyndns.org/. They offer both a free domain underneath one of their domains ( example: you may register domain emailssent.dyndns.org with them, and then havean email address of
emailssent@emailssent.dyndns.org ), or you can purchase a domain and have them host it in DNS - meaming when someone is looking for the an computer in your domain, they will query the DNS servers at dyndns.org for that information. Dyndns supports both static and dynamic IP addresses for hosts in your domain, and there are many "autoupdater" programs that will update your IP address in their DNS for you.
That is just who I use, there are many, many DNS hosting companies, and it's possible you could host your own domain on your own DNS server, but that depends on a lot of things, including your ISP.
So here is how far we have gotten, this assumes you have only one public IP address such as a DSL or cable modem connection -
*SMTP server reads email from send queue with 'to' address in your domain
*Queries DNS for your SMTP Gateway's IP address and gets an answer from DNS host with your IP address
*Contacts mail server at that IP address
*Attempts to send email
For the two parts to work, you need to have a mail server running that is configured to accept email for your hosted domain, is accepting connects on port 25, and is reachable from the Internet on port 25.
I have a Linux firewall running that also handles NAT ( network address translation, aka IP Masquerading ) for my home network as my computers at home all have private IP addresses and share one public IP address. My firewall is configured to allow incoming connections to port 25 through, and the NAT part is told that connections to port 25 go to the IP address of my mail server.
On top of that, I have my mail server configured as mentioned above. It is import that your mail server is configured to severly restrict email for sending. This is because spammers like to use other people's mail servers for sending their junk out, and have quite a few tricks up their sleeves to accomplish this task. In addition , it is a good idea to filter incoming email , too. The benefit is that if your mail server rejects spam right away, you don't need any client side spam filtering to block junk email, as it never gets to your workstation computers.
Here are some good restriction:
Sending -
*Only accepts email for sending ( aka relaying ) from computers on your network - I have the mail server check the
hostname and the IP address of the sender to allow them to send email through my mail server.
*Only sends email with a 'from" address in your domain. I have seen ( in mail server logs ),people try to send email
with a "from" different than my domain through my mail server. It didnt' go anywhere thanks to this restriction.
Recieving -
*Do reverse DNS lookup on connecting SMTP gateway, to make sure it is a registered mail server for the senders domain. Spammers usually make up domains and email address for the "from" part of the junk email, and odd are their spam mail server isn't registered for any domain.
*use access lists that block email from domains that gets past the first two rules, I have only 3 entries in my "reject" list and do not get any junk mail, at all. That shows how effective the first two rules are.
Well, that should get your started. As mentioned above, you could set up a DNS server on your local (home) network, have it resolve a domain of your choice to IP addresses for you, and then set up and test your mail server internally before messing with making it available on the Internet. I actually do both ( internal and external DNS ), but that is because I am a glutton for punishment
Let us know if you have any more questions or issues with getting a mail server running, there are a lot of knowledgable people that read this forums, so odds are you will get some good advice.