function testIsEmailAddress() { $validEmails = array('*****@*****.**', 'will.buckner [at] eggheads [dot] org', 'will.buckner (at) eggheads (dot) org', 'will.buckner@eggheads [dot] org', 'will.buckner [at] eggheads.org', 'will.buckner[AT]eggheads[DOT]org', 'will.buckner at eggheads dot org', 'wcc [at] lists [dot] nospammonkeys [DOT] org'); $invalidEmails = array('i am at the movies dot dot dot', 'not@valid', '*****@*****.**', 'my e-mail address is will.buckner [at] eggheads [dot] org'); foreach ($validEmails as $key => $value) { $this->assertTrue(StringUtility::isEmailAddress($value), sprintf("'%s' should be recognized as an e-mail address", $value)); } foreach ($invalidEmails as $key => $value) { $this->assertFalse(StringUtility::isEmailAddress($value), sprintf("'%s' should not be recognized as an e-mail address", $value)); } }
protected function _extractEmailAddress() { foreach ($this->_addressBlock as $lineNumber => $line) { if (!StringUtility::containsEmailAddress($line)) { continue; } /* Extract and properly format the e-mail address. */ $emailAddress = StringUtility::extractEmailAddress($line); /* If there is more on this line, remove the e-mail address from * the line. Otherwise, just delete the line. */ if (!StringUtility::isEmailAddress($line)) { $line = StringUtility::removeEmailAddress($line, true); $this->_addressBlock[$lineNumber] = $line; } else { unset($this->_addressBlock[$lineNumber]); $this->_addressBlock = array_merge($this->_addressBlock); } return $emailAddress; } return ''; }