کد:
http://www.thecodefish.com/Servers/Configuring_DNS_for_email_delivery
These guidelines apply to any type of SMTP mail server, including large commercial systems like
Exchange Server,
Notes Domino,
Groupwise,
Kerio Mailserver and smaller systems or freeware like
hMailserver,
Sendmail,
Mercury and
VPop.
In order to receive email, at a basic level there are 2 DNS records that are required. Most domain hosting providers offer a control panel nowadays where you can set this up yourself. Updating domain records takes time, so if you can get this done in advance. A typical propagation time can be anything up to 48 hours.
Receiving Mail
The A Record
This provides a mapping between hostnames and IP addresses. You will need to allocate a public static IP address to your mail server - most people will actually assign this to their firewall and use port forwarding to get mail to the actual mail server itself.
You will need to add an A record for the public name you want your mail server to be known as. For example, if your domain is
mycompany.com then you might call your mail server
mail.mycompany.com
Don't get confused with the domain name of your website, thats probably on another server anyway and will have a different hostname. Go to the domain control panel and enter the public IP address of the mail server and the hostname.
If you've done this correctly, once the propagation has completed you should be able to go to a command prompt and type
PING mail.mycompany.com and you will get a response that includes the IP address of your mail server. You should also be able to telnet to the server on the SMTP port (usually 25). Go ahead and type
TELNET mail.mycompany.com 25
Your mail server should connect and show you a waiting cursor and probably some sort of message maybe like this:
220 mycompany.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at
Fri, 23 Jan 2009 15:24:52 +0000
The MX Record
This Mail Exchanger record provides information to other mail servers, as to which machine they should send email messages for your domain. MX records need to have a fully qualified domain name (FQDN) of the host. The FQDN includes a trailing
. so in our example above the FQDN would be
mail.mycompany.com.
You can have several MX records for your domain if you have several mail servers. Each MX record is assigned a priority, lower numbers are more important and take precidence. Equal priorities can be used for load balancing setups. If a lower priority server is tried and is unavailable, the next highest priority server is tried and so on.
Go ahead and add your MX record. In our example we might add
MX mail.mycompany.com. 10
Sending Mail
The SPF Record
The Sender Policy Framework isn't mandatory, but is a good idea as it will help to a) stop a spammer from sending mail that appears to be from you but is sent by another server; and b) might stop those that have been spammed from sending irrate or response messages back to you. Use the online tool to generate your SPF record then add it to your DNS configuration. In some cases you may have to raise a support ticket with your Domain hosting provider as many do not have the facility to add an SPF record through their control panel just yet.
More info on this initiative is available here:
http://www.openspf.org
The PTR Record
This record provides the reverse of the A record ie. it maps an IP address back to a hostname. You may hear it described as rDNS or reverse DNS. Often mail server administrators add this check to their server to make sure that the IP address of the sending mail server actually matches the hostname, and may bounce or demote messages from servers that don't. Again it's not mandatory but really is good practice if you want reliable mail delivery for your clients.
To setup a PTR record, you will need to contact your own ISP, NOT your domain hosting provider. The ISP needs to assign the PTR along with the hostname and IP address. Again you'll probably have to raise a support ticket to get this done