PHP instance -- verify whether the email host exists

Source: Internet
Author: User

On the Internet, you must enter a maximum of email addresses for registration, and then some websites require email activation and authentication. Imagine that some users just want to download or read some content before they can register. Can those emails be used? I would like to write more mail addresses like asfsagdfg@adfdlknsafdf.com. There is no problem in verifying the email format in the background, and then the background starts sending emails. How serious is the waste of resources?ProgramAfter waiting for half a day, the result times out, so the system resources are consumed. Is there a way to verify the mail format and whether the mail host itself is correct?

Today, I read a book and read many PHP network-related functions, such as viewing DNS records (dns_get_record), obtaining host MX records (getmxrr), and obtaining server port numbers (getservname) and socket, mail, and other functions.

Since PHP has so many good functions to view the status of the host domain name, why not write a host verification function, which saves both bandwidth and valuable system resources:

   
     php   $ A  = filter_var ('sa _ d-fs.a12d@163.com ',  filter_validate_email );   $ site  =  explode  ('@',  $ A  );   $ result  = Che Ckdnsrr ($ site  [1], 'mx ');   echo  ($ result  ); ?>   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.