Mail server dns records
A crucial topic!
To set up a mail server, you need to configure DNS (Domain Name System) records to direct email traffic to your mail server. Here are the essential DNS records you need to set up:
- MX (Mail Exchanger) Records: These records specify the mail server responsible for accepting email messages on behalf of your domain. You need to create a record for each mail server you have, with a priority value (lower values have higher priority). For example:
IN MX 10 mail.example.com
IN MX 20 mail2.example.com
- A (Address) Records: These records map your domain name to the IP address of your mail server. You need to create an A record for each mail server you have. For example:
IN A 192.0.2.1
(points to the IP address ofmail.example.com
)
- TXT (Text) Records: These records provide additional information about your mail server, such as its authentication settings. You need to create a TXT record with the following values:
IN TXT "v=spf1 a mx ip4:192.0.2.1 ~all"
(SPF record to prevent spam)IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC..."
(DKIM record for email authentication)
- PTR (Pointer) Records: These records map an IP address to a domain name. You need to create a PTR record for each IP address of your mail server. For example:
IN PTR mail.example.com. 192.0.2.1
(points the IP address192.0.2.1
to the domain namemail.example.com
)
- NS (Name Server) Records: These records specify the name servers responsible for your domain. You need to create an NS record for each name server you have. For example:
IN NS ns1.example.com
IN NS ns2.example.com
Here's an example of what your DNS records might look like:
example.com. IN MX 10 mail.example.com
example.com. IN MX 20 mail2.example.com
mail.example.com. IN A 192.0.2.1
mail2.example.com. IN A 192.0.2.2
example.com. IN TXT "v=spf1 a mx ip4:192.0.2.1 ~all"
example.com. IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC..."
192.0.2.1 IN PTR mail.example.com.
192.0.2.2 IN PTR mail2.example.com.
example.com. IN NS ns1.example.com
example.com. IN NS ns2.example.com
Remember to update your DNS records with your registrar or DNS provider, and allow time for the changes to propagate globally (usually within 24-48 hours).