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 psmtp.com, 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 psmtp.com 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 “psmtp.com”  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.

<html>
<head>
<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">
</head>
<body>
<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>
<hr>
<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>
</form>
<div id ="result">
<?php
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' >";
echo"<th>";
echo"Result";
echo"</th>";
echo"<tr>";
echo"<td>";
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']) ;
}
echo"</td>";
echo"</tr>";
} else {
echo('No MX record exists.Invalid Email.');
}
echo"</td>";
echo"</tr>";
echo"</table>";
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

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(http://fonts.googleapis.com/css?family=Raleway);
body{
margin: 0 auto;
padding: 0 auto;
}
#main{
width: 100%;
margin: 1% auto;
font-family:raleway;
}
span{
color:red;
}
h1{
text-align:center;
font-family:raleway;
}
h2{
background-color: #FEFFED;
text-align:center;
border-radius: 10px 10px 0 0;
margin: -10px -40px;
padding: 15px;
font-family:raleway;
}
hr{
border:0;
border-bottom:1px solid #ccc;
margin: 10px -40px;
margin-bottom: 30px;
}
#login{
width: 289px;
border-radius: 10px;
font-family:raleway;
border: 2px solid #ccc;
padding: 10px 40px 33px;
margin-top: 23px;
margin: 0 auto;
}
input[type=text],input[type=password]{
width:99.5%;
padding: 10px;
margin-top: 8px;
border: 1px solid #ccc;
padding-left: 5px;
font-size: 16px;
font-family:raleway;
}
#email{
width:99.5%;
padding: 10px;
border: 1px solid #ccc;
padding-left: 5px;
font-size: 16px;
font-family:raleway;
}
input[type=submit]{
width: 98%;
background-color:#FFBC00;
color: white;
border: 2px solid #FFCB00;
padding: 10px;
font-size:20px;
cursor:pointer;
border-radius: 5px;
}
#profile{
padding:50px;
border:1px dashed grey;
font-size:20px;
background-color:#DCE6F7;
}
i{
color: black;
padding: 18px;
margin: 20px;
}
#right{
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;
}
#paypal_logo{
margin: 10px 315px;
float: right;
}
#dsubmit{
margin-top: 5px;
margin-bottom: 20px;
}
table {
font-family: 'Raleway', sans-serif;//
color:#666;
font-size:12px;
text-shadow: 1px 1px 0px #fff;
background:#eaebec;//
margin:20px;
border:#ccc 1px solid;
font-size: 16px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
-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;
padding-left:20px;
}
table tr:first-child th:first-child {
-moz-border-radius-topleft:3px;
-webkit-border-top-left-radius:3px;
border-top-left-radius:3px;
}
table tr:first-child th:last-child {
-moz-border-radius-topright:3px;
-webkit-border-top-right-radius:3px;
border-top-right-radius:3px;
}
table tr {
text-indent: center;
padding-left:20px;
}
table td:first-child {
text-align: center;
padding-left:20px;
border-left: 0;
}
table td {
padding:18px;
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 {
-moz-border-radius-bottomleft:3px;
-webkit-border-bottom-left-radius:3px;
border-bottom-left-radius:3px;
}
table tr:last-child td:last-child {
-moz-border-radius-bottomright:3px;
-webkit-border-bottom-right-radius:3px;
border-bottom-right-radius:3px;
}
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 –