How to check for a duplicate email address in PHP, considering Gmail (user.name+label@gmail.com)

前端 未结 7 1376
孤城傲影
孤城傲影 2021-01-01 04:48

How can I check for duplicate email addresses in PHP, with the possibility of Gmail\'s automated labeler and punctuation in mind?

For example, I wan

相关标签:
7条回答
  • 2021-01-01 05:14

    I have extended Zend Validator like this.

    <?php
    class My_Validate_EmailAddress extends Zend_Validate_EmailAddress
    {
        public function isValid($value)
        {
            $valid = parent::isValid($value);
            if ($valid
                    && in_array($this->_hostname, array('gmail.com', 'googlemail.com'))
                    && substr_count($this->_localPart, '.') > 1) {
                $this->_error(parent::INVALID_HOSTNAME);
                $valid = false;
            }
            return valid;
        }
    }
    

    Email with more than one "dot" symbol in gmail address are considered invalid. For some cases this is not logical solution, but that works for me.

    0 讨论(0)
提交回复
热议问题