![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
![]() |
Virtual Domains - a guide
Unlike web servers there are two basic types of virtual domains for a mail server:
- Real IP based virtual domains, where you have allocated an IP address to each virtual domain, the server can use this information to figure out which domain it should 'pretend' to be.
- Fake ones, where you only use a single IP address, then the user must login as 'user@domain.name' when fetching their Email via POP so that the server can figure out which domain they belong to.
SurgeMail supports both of these methods or even combinations of them and any number of virtual domains. However, it supports some other systems too :-). For example, you can tell SurgeMail to respond to all domains matching a specific wild card eg: *.mydomain.com You can also use a virtual user table where each user is in a 'domain of their own' (this is useful if you want to sell users their own domain names).
In addition, some mail clients do not allow a user to specify user@domain.name as their 'username'. In this case you can define a domain separator like '/' and then the user can login as 'user/domain.name'
Multiple domains using SurgeMail and WebMail webinterface
When using WebMail and the user.cgi the virtual domain is normally automatically identified from the URL typed in your browser (using the SERVER_NAME variable). If you prefer to have a drop down list of domains displayed, you can do this by setting the following SurgeMail setting:
g_user_domainlist "user"and the following webmail.ini setting:domain_select true
How to create a virtual domain
Simply click on 'domains' 'add' in the web admin tool. Then fill out the details.
In addition if you are using WebMail you may need to add these domains to webmail.ini as described.
Note: SurgeMail will not create the directory structure until a message is received for the new domain, so don't panic if you can't see the domains directory right away.
You can define default settings for new domain by creating/editing the domain_defaults.txt file in the SurgeMail "web" directory. This file contains only basic settings in the form:
<setting_name><space><setting_value>
one setting per line. It cannot handle the more complex settings eg.
setting label="value" label2="value2"
Adding IP numbers to your operating system
It is fairly easy to add multiple IP numbers for a single machine, up to 255 per interface is fairly straightforward. 1024 is usually possible with minor patches. The exact method varies. On NT just specify extra numbers in the networking control panel.
For UNIX, see http://www.nethelp.no/net/vif/readme.html for more information.
As an example, on Linux you would do the following:
su - root
ifconfig eth0:2 999.59.4.31 up
to add a second IP number 999.59.4.31. The number :2 can be anything between :1 and :255Virtual Domain User (domuser.dat)
If every user on your system is in their own domain, e.g. bob@jones.mail.com, john@smith.mail.com then you probably don't want to create a virtual domain entry in surgemail.ini for all 200,000 users. Instead you can use the file domuser.dat to list each user so that SurgeMail knows what virtual domains exist on your system.
The format is:
delivery_user_domain user_database_lookup_namee.g.xxx@bob.com xxx@bob.com yyy@yyy.com yyy@bob.com *@ccc.com ccc@bob.comSo with the above file, if a user 'fred@ccc.com' logged in they would be looked up in the userdatabase as 'ccc@bob.com' and yyy@yyy.com would be looked up as 'yyy@bob.com'
This file is very efficient and can support millions of virtual domains on a single server.
MX records DNS entries etc...
DNS stands for "Distributed Name Server", and it is the mechanism whereby your.domain.name is translated into your IP number (e.g. 13.2.44.2 etc). When you setup a mail server you will need to add a DNS entry. Normally this is done when you register a domain. Your domain registration service should also let you specify the IP number that your computer uses.
In addition, they may let you specify MX records. These are used as an over-ride, as a mail server for xxx.com may not run on the same computer that handles web pages for xxx.com. Also for redundancy you can specify 2 or more computers to receive Email for your domain, so if one system is down the other will accept the mail and hold it until your main system is up.
All the following examples really only apply to you if you run your own DNS server. Most likely someone else is running one for you (your ISP or domain registrar), so they will be adding these entries, but you still need to understand these entries so you know what to ask them to add to their DNS server.
For your mail server to work you must at least have a DNS or MX entry for your system e.g. typical entries look like this:
mail.freemail.com. in a 10.0.0.12
Alternatively, or as well, you can use MX records. Typically these are used to give a backup mail server address, e.g.mail.freemail.com. mx 10 mail1.freemail.com. mail.freemail.com. mx 20 mail2.freemail.com. mail1.freemail.com. in a 10.0.0.12 mail2.freemai.com. in a 10.0.0.13 mail.freemail.com. cname mail1.freemail.com.This says send all Email to mail1.freemail.com if possible. Failing that, send to mail2.freemail.com. Then the next two lines give the IP addresses of those two systems, and the last line is for dumb systems that don't know how to do MX lookups so they will find the primary system anyway.
Often you would setup the low priority MX entry to point to a system outside your local LAN, but if so, you must ensure they are configured to allow forwarding of Email to your system. Then while your system is down they will collect incoming Email for you.
Lastly you may want to configure wild card entries if you have lots of virtual domains all under a primary domain name, e.g.
*.freemail.com. mx 10 mail1.freemail.com
*.freemail.com. cname mail1.freemail.comBeware - wild card entries are not as simple as they look. In particular, it cannot be guaranteed if the MX or IN entry will be used.
You should also specify a reverse DNS entry for your mail server. If you don't some other mail servers might treat you as a spammer and block or ignore all your Emails.
When mail.your.domain and your.domain are NOT the same system
The basic problem is you want user@your.domain to go to your mail server, but you want http://your.domain to go to your web server, and they are different systems.
This is achieved by the following magic incantations.
- Add MX records to point your.domain to mail.your.domain
- Add aliases for the domain in surgemail.ini so it will accept mail for mail.your.domain as well as your.domain, host_alias "mail.your.domain" (in each domain)
- Add g_server_name url="*.domain.com" name="domain.com" so that web connections will figure out the right domain
- In webmail.ini the imap server etc should be defined as 'mail.your.domain' not 'your.domain'
So in your DNS you have:
- mail.your.domain --> x.x.x.x (your mail server)
- your.domain --> y.y.y.y (your web server)
- your.domain MX --> mail.your.domain
When you add a domain in SurgeMail it will ask you about your 'DNS' and 'MX' names, if you specify them as different, it will correctly setup your webmail.ini and surgemail.ini to cope, but you still need to setup the correcdt DNS/MX records in your DNS server.