This question gets into the realm of DNS and Ports. You indicated that you are running a web server (www.example.com
) on a hosted system, but it wasn't clear if you will be running the mail server on that same system.
When you point a browser at www.example.com
, a DNS query is automatically resolve the name (example.com) into an IP address. The name is broken down recursively with the dots as a separator. If no short cuts are taken, first, the .com (name) server will point to example.com's name server. Example.com's name server, when queried will give the address of "www" or the web server. The web server connects, by default, on port 80.
With a mail transfer agent, such as postfix, mail will be handled on port 25, so yes you can use the same server for both. Typically, when you configure a mail server, the DNS is configured with what is called an MX record. An MX record is like an A (address) record that says the server that handles mail for this domain is named XXX.example.com., and is located at address a.b.c.d. The MX records have a priority associated with them, so it is possible to have multiple mail servers for a domain.
This is important to you because you CAN configure the www (web) serve to be different than your mail server, with different addresses. To do this you need to add an MX record to your DNS. If you don't have an MX record, mail will typically be handled by the base/main server for the domain. What I mean by this is that your server is probably at example.com and www is an alias name for example.com. Without the MX record, mail will be directed towards the machine at example.com. If you are putting the mail server on the hosted system, along with your web server, this is fine and you shouldn't have to do much, if anything.
To summarize (what I think you want to do) to use the same domain name, but have your mail at a different location, give your mail server a different subdomain name, like mail.example.com and configure the MX record to point to it. If you are running on a dynamic IP address, this can get more complicated as it will need to be publicly locatable and you will need to use a (free) service like DynDNS to do that as well as probably relay your outgoing mail through your ISP's SMTP server.