How to realize the basic judgment of common mailbox in PHP

Source: Internet
Author: User
Tags mail

  Before the message is sent, the user's basic information already exists in the database, if it is a bad mailbox or malicious multiple registration account that need to filter, the following for you to introduce the implementation of PHP common mailbox in the judgment

More and more Web sites want users to register with the mailbox, or to bind the mailbox, this time to confirm the correctness of the mailbox, some people use to send mail to activate the way to judge, thus activating an account, but there is a problem is, in the mail before sending out, The user's basic information already exists in the database. If it is a bad mailbox or malicious multiple registration account, it will cause the inactive account too much, occupy the database storage space, this side needs to do before the filtering of these mailboxes, so the author wrote down a method to filter the mailbox.   Code as follows:/**  * @todo user input Security detection   * @param $inputString user input information   * @return true/false  * @final can be based on Its own requirements for filtering the content of the transformation   */  public Function checkuserinput ($inputString) {  if (strpos (' script ', $inputString)! =false) {//Detect if Script scripts   return false; }else if (Strpos (' iframe ', $inputString)!=false) {//detect if an IFRAME frame is included   return false; }else {  return true; } }   /**  * @todo checkeemail  * Param emailstring  * @return false/true  */  public Function Checkemail ($emailString) {  if ($this-&G T Checkuserinput ($emailString) = = TRUE) {//Detect if sensitive words   if (Strpos (' @ ', $emailString)!= FALSE) {//Detect presence @ Character   $ Emailarr = explode (' @ ', $emailString);  if (count ($EMAILARR) > 2) {//Detect presence of multiple@ character   return false; }else{  if (In_array (' @ '. $EMAILARR [1], Yii::app ()-> params[' Mail_suffix '])) {// Detect if suffixes meet daily common mailbox suffixes   return true; }else{  return false; } } }else{  return false;& nbsp } }else{  return false; } }    in which I defined an array of commonly used mailbox suffixes, as follows:   //Common mailbox suffix, According to the specific requirements can be added   code as follows: ' Mail_suffix ' =>array (' @hotmail. com ',  ' @msn. com ',  ' @yahoo. com ',  ' @ gmail.com ',  ' @aim. com ',  ' @aol. com ',  ' @mail. com ',  ' @walla. com ',  ' @inbox. com ',  ' @ 126.com ',  ' @163.com ',  ' @sina. com ',  ' @21cn.com ',  ' @sohu. com ',  ' @yahoo. com.cn ',  ' @ Tom.com ',  ', @qq. com ',  ' @etang. com ',  ' @eyou. com ',  ' @56.com ',  ' the @x.cn ',  ' Chinaren.com ',  ' @sogou. com ',  ' @citiz. com ',  ',    to this mailbox filtering method is completed, we can further improve on this basis!  
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.