Esempio n. 1
0
 function CopyAddresses($message, &$results, $header)
 {
     if (!isset($message['Headers'][$header])) {
         return;
     }
     if (!isset($message['ExtractedAddresses'][$header])) {
         $parser = new rfc822_addresses_class();
         $parser->ignore_syntax_errors = $this->ignore_syntax_errors;
         $values = GetType($message['Headers'][$header]) == 'array' ? $message['Headers'][$header] : array($message['Headers'][$header]);
         $tv = count($values);
         $addresses = array();
         for ($v = 0; $v < $tv; ++$v) {
             if ($parser->ParseAddressList($values[$v], $a)) {
                 if ($v == 0) {
                     $addresses = $a;
                 } else {
                     $tl = count($a);
                     for ($l = 0; $l < $tl; ++$l) {
                         $addresses[] = $a[$l];
                     }
                 }
             }
         }
     } else {
         $addresses = $message['ExtractedAddresses'][$header];
     }
     if (count($addresses)) {
         $results[ucfirst(substr($header, 0, strlen($header) - 1))] = $addresses;
     }
 }
Esempio n. 2
0
<?php

/*
 * test_parse_addresses.php
 *
 * @(#) $Header: /home/mlemos/cvsroot/mimeparser/test_parse_addresses.php,v 1.5 2008/01/08 18:48:35 mlemos Exp $
 *
 */
require_once 'rfc822_addresses.php';
$parser = new rfc822_addresses_class();
$addresses = array('*****@*****.**', '"quoted test"@test.com', 'test name <*****@*****.**>', 'test.name <*****@*****.**>', '"test@name" <*****@*****.**>', 'test@name <*****@*****.**>', '"test\\"name" <*****@*****.**>', 'test@test.com (test name)', 'test@test.com, test name <*****@*****.**>', 'Isto é um teste <*****@*****.**>', 'Isto =?iso-8859-1?q?=E9_um_teste?= <*****@*****.**>', '"Isto é um teste" <*****@*****.**>', 'undisclosed-recipients:;', 'undisclosed-recipients:; (some comments)', 'mailing-list: test@test.com, test name <*****@*****.**>;, another test <*****@*****.**>');
$c = count($addresses);
for ($a = 0; $a < $c; ++$a) {
    if (!$parser->ParseAddressList($addresses[$a], $parsed)) {
        echo 'Address extraction error: ' . $parser->error . ' at position ' . $parser->error_position . "\n";
        break;
    } else {
        echo 'Parsed address: ', $addresses[$a], "\n";
        var_dump($parsed);
        for ($warning = 0, Reset($parser->warnings); $warning < count($parser->warnings); Next($parser->warnings), $warning++) {
            $w = Key($parser->warnings);
            echo 'Warning: ', $parser->warnings[$w], ' at position ', $w, "\n";
        }
    }
}