MX-Record is also known as mail exchanger record (MX record). It is a type of record in the Domain Name System that points out to a mail server which is responsible for accepting email messages on behalf of a receiver domain.

An MX Record is a perfect(Route-Map) address of any domain(usually Email Receiver). So, when a user want to send an email to another user then user’s mail server must know the receiver IP address. Sender mail server sends a query to DNS. When DNS gets this request then DNS search for the request related Receiver records. This record is known as MX-Record.

In this blog post, we are going to clean email list on the basis of MX-Record.

If you want to learn the full concept about MX-Record,  you must need to have basic knowledge about DNS(Domain Name Server/System).
If you don’t have any idea about DNS, then Please visit This link Domain Basics

Watch the live demo or download code from the link given below

MailGet is an online Email Marketing sevice which allow you to send Bulk Emails with list cleaning features. You can easily connect and configure it with different SMTP service providers, e.g MailGun, Mandrill, Postmark etc, to send Emails.

The questions which come very first in user’s mind are listed below with proper explanation.

Why do we need MX records.?

When your domain is registered, it’s assigned several DNS records, which enable it to be located on the Internet. These include MX records, which direct the domain’s mail flow.

Each MX record points to an email server that’s configured to process mail for that domain. There’s typically one record that points to a primary server, then additional records that point to one or more backup servers. For users to send and receive an email, their domain’s MX records must point to a server that can process their mail.

How does it looks.?

This picture image will let you show the MX-Record Format.

mx record concept explaination


  1. Name:  Name of Email-Sender Domain.
  2. Class: This is always set to IN, which stands for the Internet.
  3. Type: For MX records, this is always set to MX.
  4. TTL: “Time to Live.” How long it will take to update the record. This is measured in seconds. A TTL of 3600 seconds means records will take an hour to update. A TTL of 86400 means records will take a day to update. A higher TTL value means less traffic load for the DNS server, but it also means that changing the MX records will take longer.
  5. Preference or Priority(PRI): The order of preference for mail delivery. Sending servers should try the lowest preference number first, then the next lowest, and so on.
  6. Data: Name of Receiver Domain or the hostname of the mail server that handles mail for that domain.

How can we update MX records.?

If your company has its own DNS servers, you can contact to your DNS administrator for update stuff. Otherwise, talk to your domain name provider.

Why should I  update my MX records.?

We route your email to us for the better security of the message. When you update your MX records, we perform the certain operation listed below.

  1. Remove out the bad emails.
  2. Send the correct & good emails to your email server.

When should I update my MX records.?

As activation process occur, you’ll receive a message asking for update your MX records.

If you’re adding more domains later on, update your MX records after you’ve added the domain in the Administration Console. Until your domain is set up in the Administration Console, mail will bounce if you update your MX records.

Why do I need to have separate MX records.?

We use redundant MX records as a backup in case any problem occurs. They give our network more flexibility if any changes to architecture are necessary.

Should I update A records when routing mail to the message security service.?

Do not update your A records. Since your MX records point to, you do not need to change any A records.

Should I keep MX records pointed directly to my mail server as a backup.?

Yes. If you want to keep a direct MX record for your mail server as a backup, you can, but be sure to leave it at the lowest priority, after all four records. Leaving your own mail server in the MX records should be a temporary backup measure, because spammers sometimes try to bypass the service and connect directly to your mail server using your backup MX records. Once your mail is flowing through the message security service successfully, consider changing your MX records to remove this backup.

How long do MX record updates take.?

MX record updates are not immediate. After you’ve updated your MX records, it will take a while for every sender to use the new MX records. Your original TTL setting determines how long (in seconds) this will take. Changing the TTL setting won’t speed this up.

Will I lose mail after changing MX records.?

No. As long as you enter the MX records correctly, you won’t lose any mail. While your MX records are changing over, some mail will be delivered using your old MX information, and some mail will be delivered using your new MX information, but all of it will be delivered.

What happens if I type the wrong information into the MX record.?

If you type the incorrect delivery information in the MX record, some mail will bounce. The sender will receive a notice that the mail wasn’t delivered. If this happens, correct the MX records as soon as possible. Some mail may still bounce for a period of time (up to the length of the new TTL setting), but the sooner you update the MX records to the correct setting, the fewer messages will bounce.

What exactly happens when I update my MX records.?

Once you update your MX records, mail will start flowing through the message security service. After your old previous TTL (in seconds) has expired, all your mail flows through the message security service. When your mail flows through the service, mail is bounced from IP addresses known to be a major source of spam attacks or viruses. Also, if you have Non-Account Virus Blocking, mail to users will be filtered for viruses as well. You’ll get complete mail filtering after you’ve added your users.

How would I know that the  MX update worked.?

If you want to check whether your MX update got successful or not, send a mail from an outside address then check in the full headers. It is a text which is about 20-30 lines long. If you find the word “”  in the header then the mail has been routed through the message security service.

Important commands related to MX-Records:-

BLACKLIST:  Check IP or host for reputation.
SMTP:  Test mail server SMTP (port 25).
MX:  DNS MX records for a domain.
A:  DNS A record IP address for hostname.
SPF:  Check SPF records on a domain.
TXT:  Check TXT records on a domain.
PTR:  DNS PTR record for the hostname.
CNAME:  DNS canonical hostname to IP address.
SCAN:  Perform a port scan on the host.
WHOIS:  Get domain registration information.
ARIN:  Get IP address block information.
SOA:  Get Start of Authority record for a domain.
TCP:  Verify an IP Address allows TCP connections.
HTTP:  Verify a URL allows HTTP connections.
HTTPS:  Verify a URL allows secure HTTP connections.
PING:  Perform a standard ICMP ping.
TRACE:  Perform a standard ICMP traceroute.
DNS:  Check your DNS Servers for possible problems.

index.php :

This index.php file contains the major functionality of the script.While executing this code user see a form, see the image above.User has to enter email address and after clicking on submit button user gets the result as MX-Record.

<link href="css/style.css" rel="stylesheet" type="text/css"/>
<title>Check Email MX Record</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<div class="container">
<div class="row">
<div class="col-sm-1 col-md-2 col-lg-12">
<div id="main" class="col-sm-1 col-md-2 col-lg-12">
<div class="col-sm-1 col-md-2 col-lg-12"><h1>Check Email MX Record</h1> </div>
<div id="login">
<h2>MX Record Checker</h2>
<div id="right">
<form name="myForm" method="post" action="index.php">
Please Enter Email Address:<br /><br />
<input type="email" size=18 name="email" id="email"><br /><br />
<div class="col-sm-1 col-md-2 col-lg-12"> <input type="submit" value="Check" id="dsubmit" name ="submit"></div>
<div id ="result">
if (isset($_POST['submit'])) {
$email = $_POST['email'];
* Getting Domain part from user input Email-Address
$domain = substr(strrchr($email, "@"), 1);
* This Function is used for fetching the MX data records to a corresponding
- Email domain

function mxrecordValidate($email, $domain) {

$arr = dns_get_record($domain, DNS_MX);
if ($arr[0]['host'] == $domain && !empty($arr[0]['target'])) {
return $arr[0]['target'];

echo"<table id ='tid' >";
if (mxrecordValidate($email, $domain)) {
echo('This MX records exists.Valid Email Address.');
$data = dns_get_record($domain, DNS_MX);
foreach ($data as $key1) {
echo "Host:- " . $key1['host'] ;
echo "Class:- " . $key1['class'] ;
echo "TTL:- " . $key1['ttl'] ;
echo "Type:- " . $key1['type'] ;
echo "PRI:- " . $key1['pri'] ;
echo "Target:- " . $key1['target'] ;
echo "Target-IP:- " . gethostbyname($key1['target']) ;
} else {
echo('No MX record exists.Invalid Email.');

style.css :

This file takes care about all designing working occuring in form, you can change it according to your requirement.

css settings for HTML div exactCenter
@import url(;
margin: 0 auto;
padding: 0 auto;
width: 100%;
margin: 1% auto;
background-color: #FEFFED;
border-radius: 10px 10px 0 0;
margin: -10px -40px;
padding: 15px;
border-bottom:1px solid #ccc;
margin: 10px -40px;
margin-bottom: 30px;
width: 289px;
border-radius: 10px;
border: 2px solid #ccc;
padding: 10px 40px 33px;
margin-top: 23px;
margin: 0 auto;
padding: 10px;
margin-top: 8px;
border: 1px solid #ccc;
padding-left: 5px;
font-size: 16px;
padding: 10px;
border: 1px solid #ccc;
padding-left: 5px;
font-size: 16px;
width: 98%;
color: white;
border: 2px solid #FFCB00;
padding: 10px;
border-radius: 5px;
border:1px dashed grey;
color: black;
padding: 18px;
margin: 20px;
width: 96.1%;
border: 1px dashed rgb(215, 215, 215);
box-shadow: 0px 5px 17px 1px #99A3AD, 0px 0px 40px #EEEEEE;
padding: 10%;
margin-left: -24px;
word-wrap: break-word;
#right p{
padding: 20px;
margin: 10px 315px;
float: right;
margin-top: 5px;
margin-bottom: 20px;
table {
font-family: 'Raleway', sans-serif;//
text-shadow: 1px 1px 0px #fff;
border:#ccc 1px solid;
font-size: 16px;
-moz-box-shadow: 0 1px 2px #d1d1d1;
-webkit-box-shadow: 0 1px 2px #d1d1d1;
box-shadow: 0 1px 2px #d1d1d1;
margin: 0 auto;
table th {
text-align: center;
padding:21px 25px 22px 25px;
border-top:1px solid #fafafa;
border-bottom:1px solid #e0e0e0;
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#ebebeb));
background: -moz-linear-gradient(top, #ededed, #ebebeb);
table th:first-child {
text-indent: center;
table tr:first-child th:first-child {
table tr:first-child th:last-child {
table tr {
text-indent: center;
table td:first-child {
text-align: center;
border-left: 0;
table td {
border-top: 1px solid #ffffff;
border-bottom:1px solid #e0e0e0;
border-left: 1px solid #e0e0e0;
background: #fafafa;
background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#fafafa));
background: -moz-linear-gradient(top, #fbfbfb, #fafafa);
word-break: break-word!important;
table tr.even td {
background: #f6f6f6;
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#f6f6f6));
background: -moz-linear-gradient(top, #f8f8f8, #f6f6f6);
table tr:last-child td:first-child {
table tr:last-child td:last-child {
table tr:hover td {
background: #f2f2f2;
background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0));
background: -moz-linear-gradient(top, #f2f2f2, #f0f0f0);
@media only screen and (max-width:480px){
#main {
width: 100%;
#login {
width: 75%;
margin: 0 auto;
input[type=submit] {
width: 98%;
table td {
word-break: break-word!important;

Conclusion :

Hope, you would  have been understood a  full concept of MX-Records from this blog post. I am sure you will give a try to the script provided and implement it in your own projects as well. Feel free to visit our website again in the future to get in touch with new coding tricks. You can let us know about your feedback in the space provided below.

You may also like –