EzDevInfo.com

mx-record interview questions

Top mx-record frequently asked interview questions

How to get mx records for a dns name with System.Net.DNS?

Is there any built in method in the .NET library that will return all of the MX records for a given domain? I see how you get CNAMES, but not MX records.


Source: (StackOverflow)

Why have MX records? [closed]

I previously asked a question regarding MX records (and appreciate the thoughtful answers I received from SO'ers). Now that that problem is resolved, I want to step back and ask why there are MX records in the first place.

Specifically: Why does SMTP get special treatment by DNS?

We don't have HX records for HTTP or FX records for FTP. It seems like every other Internet protocol gets along just fine with DNS' A record. Indeed, the Wikipedia article on MX records states that the current SMTP spec says that if an MX record does not exist for a receiver, the server should fall back on an A record. It also mentions some accommodations SMTP made in a pre-DNS world, but that was 25 years ago. Do we really need MX records any more?


Source: (StackOverflow)

Advertisements

Finding the MX Record using C#?

How can I find the MX record for a mail server in C#?


Source: (StackOverflow)

Creating mail account not a mailbox using imap in php

We all know how to open a mailbox using imap_open. Here the problem is i'm creating a maill system here. I'm not able to find to create a mail account with imap/pop3 in php. Is it is possible ?

Assume suppose my domain is www.studentmug.com. I want to create a mail for another user with out using cPanel. Ex:- radhakrishna@studentmug.com. I'm not finding any script for it in IMAP section. could any one got this problem or solution ?

Please share your opinions & suggestions - Thanks in advance.


Source: (StackOverflow)

Mailgun messages from subdomain without MX record get rejected by some mail-providers

I'd like to use Mailgun to send e-mails from a web application, sending newsletters as well as transactional mails.

I set up a sudomain "subdomain.domain.tld" and configured the DNS as specified on the Mailgun panel, except for the (optional) MX record needed to recieve mail at that subdomain. This is because the current hoster/domain-registrar doesn't allow setting an MX record for subdomains, just for the main domain. Their support says something like 'We don't care about this, deal with it.'.

I don't want to configure the main domain for the use by Mailgun, as the client is recieving regular e-mail the main domain that is handled by other servers.

The current setup allows me to send mail using mailgun with the "From"-address "mail@domain.tld" to most major E-Mail providers including Gmail, Yahoo and Hotmail. However the mails get rejected by some providers (e.g. mail.ru, freenet.de or arcor.de), with an error messages like the following:

<bounce+gibberish-user@=provider@subdomain.domain.tld>: Sender address rejected: Domain not found

Other providers have slightly different messages, but point to the same problem:

  • Domain of sender address [..] does not exist.
  • Unrouteable mail domain, verifying bounce failed
  • Unroutable sender address

It seems to me that the mails get rejected because of the missing MX record for subdomain.domain.tld , as used within the bounce address.

How do I solve this problem without moving the complete domain to another registrar that allows me to change MX records for subdomains? I would really like to avoid this.

Is it possible to configure mailgun to use different bounce addresses that are actually valid independent of my MX records? For example bounce-gibberish-mydomain-tld@mailgun.com instead of bounce-gibberish@mydomain.tld?


Source: (StackOverflow)

Using MX records to validate email addresses

Scenario:
I have a contact form on my web app, it gets alot of spam.
I am validating the format of email addresses loosely i.e. ^.+@.+\..+$
I am using a spam filtering service (defensio) but the spam scores returned are overlapping with valid messages. At a threshold of 0.4 some spam gets through and some customer's questions are wrongly thrown in a log and an error displayed.

All of the spam messages use fake email addresses e.g. zxmzxm@ywduasm.com

Dedicated PHP5 Linux server in US, mysql, logging spam only, emailing the non spam messages (not stored).

Proposal: Use php's checkdnsrr(preg_replace(/^.+?@/, '', $_POST['email']), 'MX') to check the email domain resolves to a valid address, log to file, then redirect with an error for messages that don't resolve, proceed to the spam filter service as before for addresses that do resolve according to checkdnsrr().

I have read (and i am sceptical about this myself) that you should never leave this type of validation up to remote lookups, but why?

Aside from connectivity issues, where i will have bigger problems than a contact form anyway, is checkdnsrr going to encounter false positives/negatives?
Would there be some address types that wont resolve? gov addresses? ip email addresses?
Do i need to escape the hostname i pass to checkdnsrr()?

Solution: A combination of all three answers (wish i could accept more than one as a compound answer).

I am using:

$email_domain = preg_replace('/^.+?@/', '', $email).'.';
if(!checkdnsrr($email_domain, 'MX') && !checkdnsrr($email_domain, 'A')){
   //validation error
}

All spam is being logged and rotated. With a view to upgrading to a job queue at a later date.

Some comments were made about asking the mail server for the user to verify, i felt this would be too much traffic and might get my server banned or into trouble in some way, and this is only to cut out most of the emails that were being bounced back due to invalid server addresses.

http://en.wikipedia.org/wiki/Fqdn and

RFC2821
The lookup first attempts to locate an MX record associated with the name.
If a CNAME record is found instead, the resulting name is processed as if 
it were the initial name.
If no MX records are found, but an A RR is found, the A RR is treated as
if it was associated with an implicit MX RR, with a preference of 0,
pointing to that host.  If one or more MX RRs are found for a given
name, SMTP systems MUST NOT utilize any A RRs associated with that
name unless they are located using the MX RRs; the "implicit MX" rule
above applies only if there are no MX records present.  If MX records
are present, but none of them are usable, this situation MUST be
reported as an error.

Many thanks to all (especially ZoogieZork for the A record fallback tip)


Source: (StackOverflow)

Can I have a different mail server for each subdomain?

Basically, some GoDaddy DNS help text has me scratching my head. Godaddy's DNS service says, "You cannot set up your domain name to use more than one mail provider at a time." But it doesn't talk about more than one subdomain name, with one mail provider per subdomain.

I think I need more than one mail server in my organization, where different subdomains use different mail servers.

That is, someone in my organization has gotten the fire to use Google Apps for a mail server.

We already have an MX record which services some GoDaddy mail forwards like user1@nonprofit.org and user2@nonprofit.org. We don't want to distrurb those. Their owners are happy with them for the time being.

It is acceptable to Mr. Google Apps Fanboy if we set up a subdomain like staff.nonprofit.org and use that for his Google Apps mailserver. So he would have an email address like user3@staff.nonprofit.org.

Given that there is already a priority 0 MX record pointed at the GoDaddy mail forwarding service, can I set up another priority 0 MX record pointed at the Google Apps mail server for email addresses on a new staff.nonprofit.org subdomain? Are priorities exclusive even for different subdomains?

If it cannot be at the same priority, do I need to make the subdomain MX record a higher priority than the domain MX record and have everything still work?


Source: (StackOverflow)

Do CNAME records also forward MX requests?

My DNS has a set up for the domain base.com that consists of A and MX records. There are several other domains that are set up with CNAME records, pointing to base.com. Do I need to set up anything special (like extra MX records) for the CNAME domains, or will the CNAME records also forward any MX requests.

Example:
Will an email sent to info@otherdomain.com be delivered correctly to the MX of base.com if these (and only these) DNS records are in place:

; A and MX set up for base.com
base.com.  3600  IN  A  123.45.67.89
mail.base.com.  3600  A  123.45.67.89
base.com.  3600  IN  MX  10  mail.base.com.
; CNAME set up for otherdomain.com
otherdomain.com. CNAME  IN  A  base.com.

Source: (StackOverflow)

Pulling MX record from DNS server

I am writing an application that is requiring me to do a DNS lookup for an MX record. I'm not sure if anyone has had experience doing this kind of work but if you do, any help would be appreciated.

EDIT: The thing that I'm going for is an application that will send an e-mail alert. The problem is I need to have the application be able to lookup the MX record for a domain.


Source: (StackOverflow)

How do I setup an MX record for a sub-domain? [closed]

Update - GoDaddy said they don't provide support for custom MX records. I gave up and we just setup an MX record on another domain.

I am hitting a road block in assistance with GoDaddy in setting up an MX record correctly and tired of waiting "24 to 48 hours" for propagation. I am going to describe this question in relation to the GoDaddy interface and use "domain.com" instead of our real domain. This may be a more general DNS question or something just peculiar to GoDaddy's interface -- I don't know yet.

We are setting up new bulk email software for a hosted email product we offer. The bulk email sends out from a different server than our company email and we need to have bounce backs for bulk jobs come back to the bulk server. This requires that we have an MX record setup for that bulk email server. This domain/mx record has been setup as a "sub-domain" of our main domain as "mail2.domain.com".

Below is the current setup at GoDaddy and a description of what we have tried. The problem is in relation to the MX record and Goes To "mail2.domain.com".

A Records

Host     Points to
@        ###.###.##.154
mail     ###.###.##.150
mail2    ###.###.##.158

MX Records

Priority    Host                Goes To
10          mail2.domain.com    mail2.domain.com
0           @                   mail.domain.com

I have tried different variations for the Host value for mail2.domain.com with no luck. GoDaddy advised me on the phone last week to use "mail2" then their interface says to use "mail2.". These didn't work so I change it about 6 hours ago to be the full domain "mail2.domain.com" with no success yet. I called them and they said the changes I made were good, which conflicts to their original adivce. Everytime I make changes I wait a day or two to be sure whether they will work so this takes a long time to go by trial and error.

Does anyone know definitively how this should be setup?

Thanks


Source: (StackOverflow)

I can't add the last Google Apps Email MX record because Zerigo DNS only allows 10 records. Will it matter?

I am using Heroku for my site hosting, and Zerigo for DNS magagement. I'm trying to setup Google Apps email, but I can't add the last MX record (ASPMX5.GOOGLEMAIL.COM.) because I have hit my limit of 10 allowed total records on Zerigo. Will it matter if I don't add this last record?


Source: (StackOverflow)

sendmail and MX records when mail server is not on web host

This is a problem I'm sure is easy to fix, but I've been banging my head on it all day.

I'm developing a new web site for a client. The web site resides at (this is an example) website.com. I have a PHP form script to email visitors' requests to requests@website.com.

When I coded this on a staging server on a different domain, all worked fine. When I moved it to website.com, the mail messages never arrived. The web server is on a virtual host with a major ISP.

Here's what I've learned since then: My client's mail server is Microsoft Exchange on a box physically in their office. Whenever someone on the outside world emails requests@website.com, the mail arrives. But if the web server sends to the same email address, it fails every time. This is not a PHP problem. I secure shell in to the web server and have tested this both with sendmail and the UNIX mail application. I've also tested it by emailing various email accounts from the shell. I can email myself, for example, just nobody at the website.com domain.

In short, when I'm logged in to website.com, mail to requests@website.com, user@website.com, another_user@website.com all fail. All other addresses work fine. What I've discovered is those dropped emails are routed to the web server's "catchall" account where they sit in its inbox.

I've done an MX lookup on website.com. The MX record points to mailsec.website.com. I can telnet to mailsec.website.com port 25 and see the SMTP server.

It appears to me that website.com isn't doing an MX lookup when it's sending mail to requests@website.com. My theory is that it recognizes the domain as local, sees that there's no "requests" user account to deliver it to, and drops the mail into the catchall account. What I want is to force sendmail to do the MX lookup and send the message on to the Exchange server. I'm at wit's end here. I can't figure out how to do this.

For that matter, I may be way off base here and have misdiagnosed this entirely. Internet mail and MX has always seemed a black art to me, and my ignorance is certainly showing in this question.


Source: (StackOverflow)

How do I setup Mandrill MX records and keep my old email?

I setup MX records for my domain. According to the tutorial, all other records should be removed. I removed the old records and have since realized that I still want a regular e-mail account,

   info@mydomain.com

How do I setup my MX records to handle this?

Mandrill's tutorial said that no other MX records are allowed.. I want to have info@mydomain route exist as well.


Source: (StackOverflow)

PHP Form not sending to email address on same server

I'm using a very simple PHP form on my websites, but the form will not send the message to any email sitting on my server I.E

pixology.net/contact.php

Will not send to brad@pixology.net But will send to bradhouston@gmail.com

Here is the code, any ideas?

<?php
if(isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "brad@tpdesign.co.uk";
    $email_subject = "TP Design Contact Form";


    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }

    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');
    }

    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required

    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";

    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }

    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Telephone: ".clean_string($telephone)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>

<!-- REDIRECTED PAGE ONCE CONTACT FORM IS SUCCESFULL -->

<?php require_once('thankyou.php'); ?>

<?php
}
?>

Source: (StackOverflow)

Redirect mail with AWS route 53 mx records

This is probably a newbie DNS problem, so bare with me.

I have two domains:

  1. mydomain.fi using AWS Route 53 DNS

  2. mydomain.com hosted on hostmonster

I am trying to set up an email address for mydomain.fi. Instead of installing a email server on EC2 or purchasing a Google Apps account my idea was to redirect mail to mydomain.fi to my other domain on hostmonster.

From hostmonster's DNS zone edit I found the records:

MX:

0 @ mail.mydomain.com 14400

TXT:

@ v=spf1 a mx ptr include:hostmonster.com ?all 14400

I added these to the Route 53 records of mydomain.fi

When testing by sending an email, myname@mydomain.com gets delivered but

myname@mydomain.fi generates the error:

Technical details of permanent failure: Google tried to deliver your message, but it was rejected by the server for the recipient domain mydomain.fi by mail.mydomain.com. [xx.xx.xx.xx].

The error that the other server returned was: 550 No Such User Here

I tried changing MX settings from Local to Remote in Hostmonster's setting but this had no effect.

What additional settings are needed in Route 53 / Hostmonster to complete the task?

Thanks a billion!


Source: (StackOverflow)