Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Create a Default MX Record Template for MX Route in DirectAdmin

Use this guide if you want every new domain on your server to send email to an outside mail service. You need Admin or root access.

DirectAdmin2 min read9 steps3 screenshots

What are these terms?

An MX record is a line in a domain's DNS settings. It tells the world which mail server receives email for that domain. DNS is like a phone book for the internet. An MX record is the mail entry in that book.

MX Route here means an outside email service that handles your mail instead of your own server. It is a third-party service. It gives you its own mail server names. Hostvento does not set these names. Find them in your account at that mail service.

A template is a pattern. DirectAdmin copies it every time you add a new domain. So if you put the outside mail servers into the template, each new domain gets them at once.

Warning: a template changes only domains you create after the change. It does not change domains that already exist. A wrong MX record stops email from arriving, so double-check the names.

Steps

  1. Collect the mail server names and their priority numbers from your mail service. Priority is the order of use. A lower number goes first.
  2. Log in to the server over SSH as root.
  3. Go to the DirectAdmin templates folder.
    Screenshot: Go to the DirectAdmin templates folder.
cd /usr/local/directadmin/data/templates
  1. Make a safe place for your own copy. DirectAdmin reads files from the custom folder first, and updates will not erase them.
mkdir -p custom
cp dns_mx.conf custom/dns_mx.conf

This copies the default MX template into your custom folder.

  1. Open the copy with nano custom/dns_mx.conf.
  2. Look at the format of the existing line. Replace the mail server name with the one your mail service gave you. Keep the same layout. Add one line for each mail server.
  3. Save the file.
  4. Create a test domain in DirectAdmin.
  5. Open DNS Management for that domain and check the MX records.

Do not forget the mail setting

For each domain, you should also tell the server not to deliver mail locally. In DirectAdmin this is done under MX Records, with the option for a remote mail server. Otherwise the server may keep mail for itself.

Screenshot: For each domain, you should also tell the server not to deliver mail locally. In DirectAdm
Screenshot: For each domain, you should also tell the server not to deliver mail locally. In DirectAdm
Tip: Ask your mail service for its recommended MX setup. Ask Hostvento support if you are unsure about the file format on your DirectAdmin version.

Quick recap

  • An MX record says which server receives a domain's email.
  • A template gives that record to every new domain.
  • Copy dns_mx.conf into the custom folder and edit the copy.
  • Only new domains are affected. Test with a new domain.