PHP

Extracts e-mail addresses

<?php
/**
 * Extracts e-mail addresses from a string
 *
 */
function mymodule_extract_mailaddresses($string) {
 
$string = check_plain($string);
 
 
$string preg_replace('/[^a-öA-Ö0-9\s@.-]/', ' ', $string);
 
 
$array = explode(' ', $string);
 
  foreach (
$array as $key => $value) {
    if(
stristr($value, '@')){
     
$email[$value] = trim($value);
     
//watchdog('test_v', 'Test: '.trim($value), WATCHDOG_DEBUG);
   
}
  }
 
 
  return
$email;
}
?>

Check e-mail address

<?php
function check_emailaddress($email){
  if(
eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](g|l|m|pa|t|u|v)?$", $email, $check)) {
    if(!
checkdnsrr(substr(strstr($check[0], '@'), 1), "ANY")) {
      return
FALSE;
    }
  } else {
    return
FALSE;
  }
}
?>

Pages