Jump to content

Can Someone Explaing This Php Function To Me?


rnmcd
 Share

Recommended Posts

Do you think this might be a poor way for me to determine if someone registering at a site has typed in an email adress in the correct format? I'm kind of afraid that I might lose registrations if the MX record doesn't exist or if the checkdnsrr doesn't function properly.

Link to comment
Share on other sites

I'm not sure I understand your question.  If you want a valid email address it has to have a valid MX entry.

 

I left out a crucial word in my last post: doesn't

 

Here is the edited post:

 

Do you think this might be a poor way for me to determine if someone registering at a site has typed in an email adress in the correct format? I'm kind of afraid that I might lose registrations if the MX record doesn't exist or if the checkdnsrr doesn't function properly.

 

You answered about question about MX records existing for each email address, thanks.

 

Could the checkdnsrr not function properly in future versions of php?

Link to comment
Share on other sites

Could the checkdnsrr not function properly in future versions of php?

That could happen but I wouldn't worry too much about it.

If the checkdnsrr doesn't work then customers (with legitimate emails) won't be able to register.

 

When you mentioned that I shouldn't worry about it, is that because future versions of php will likely support checkdnsrr or that if checkdnsrr doesn't function with later php versions it shouldn't cause any problems with entering an email address.

 

Thank you Bruce.

Link to comment
Share on other sites

  • 3 weeks later...
It supposedly checks every domain to see if it has an MX record in the DNS.

 

 

 

So if someone tries to register with the email name@yahoo.com and yahoo is down at the time, will checkdnsrr see that as yahoo not having MX record?

 

I'm must not completely understanding how a domain is checked to see if it has a MX record....

 

Thank you.

Link to comment
Share on other sites

Not true, I don't think.  An MX record is like a DNS record.  It's a domain record for the mail exchange.  As long as the name servers handling the MX record was not down it wouldn't matter if yahoo.com was down or not.

 

Someone correct me if I am worng.  :blink:

 

 

Bruce, you're everywhere this morning!!! flying from forum to forum!!! :1eye:

 

If you are correct about an MX record being a domain for the mail exchange, can/do name servers that handle MX records go down too?

Link to comment
Share on other sites

I assume that the PHP function would cause the server to do a DNS lookup on IT'S OWN default DNS name server. If that server were down/not working it should try the secondary. If they're all down/malfuntioning, then you would not get a response and, yes, registration probably would fail. Whether the registering user's DNS or mail servers are up at the moment would not affect the process at all.

 

Easier way would be to use getmxrr() , which is designed specifically for checking MX records. Be aware that this will only protect you from people trying to give emails from non-existent domains or mis-typed domains. It doesn't give any assurance that the username part of their email is correct.

 

As for worrying about the function disappearing, the tendency in PHP has always been to create more and more and more functions, and to allow old functions to exist for many versions after the decision is made that they should be gotten rid of.

Link to comment
Share on other sites

I assume that the PHP function would cause the server to do a DNS lookup on IT'S OWN default DNS name server. If that server were down/not working it should try the secondary. If they're all down/malfuntioning, then you would not get a response and, yes, registration probably would fail. Whether the registering user's DNS or mail servers are up at the moment would not affect the process at all.

 

Easier way would be to use getmxrr() , which is designed specifically for checking MX records. Be aware that this will only protect you from people trying to give emails from non-existent domains or mis-typed domains. It doesn't give any assurance that the username part of their email is correct.

 

As for worrying about the function disappearing, the tendency in PHP has always been to create more and more and more functions, and to allow old functions to exist for many versions after the decision is made that they should be gotten rid of.

 

Thanks for the very interesting information.

 

Regarding using checkdnsrr vs. getmxrr

http://us3.php.net defines:

getmxrr -- Get MX records corresponding to a given Internet host name

 

checkdnsrr -- Check DNS records corresponding to a given Internet host name or IP address

 

What advantages would getmxrr have over checkdnsrr? Does checkdnsrr do an additonal step that isn't needed if all I want to do it verify an MX record?

 

thanks.

Link to comment
Share on other sites

Basically checkdnsrr lets you do any kind of DNS queries, whereas getmxrr JUST does MX records. If you're doing a very simple "does this domain exist" query then checkdnsrr() works fine. But getmxrr() actually returns the results into an array if you wanted to do deeper checking. Below are two tutorials about how you might do this:

 

Here is a good tutorial on the topic:

http://www.devshed.com/c/a/PHP/Email-Addre...ation-with-PHP/

 

RNMCD already posted this great tutorial on this topic:

http://gurusnetwork.com/tutorial/geekspeak/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...