Login   Register  
PHP Classes

File: test_parse_addresses.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Manuel Lemos  >  MIME E-mail message parser  >  test_parse_addresses.php  >  Download  
File: test_parse_addresses.php
Role: Example script
Content type: text/plain
Description: Example to demonstrate how to parse e-mail address lists
Class: MIME E-mail message parser
Decode MIME e-mail messages
Author: By
Last change: Added support to tolerate escape characters in e-mail address names that
are not quoted.
Fixed decoding of q-encoded values in e-mail addresses.
Date: 2 years ago
Size: 1,644 bytes


Class file image Download
 * test_parse_addresses.php
 * @(#) $Header: /opt2/ena/metal/mimeparser/test_parse_addresses.php,v 1.7 2011/10/29 09:11:50 mlemos Exp $

$parser = new rfc822_addresses_class;

$addresses = array(
'"quoted test"@test.com',
'test name <test@test.com>',
'test.name <test@test.com>',
'"test@name" <test@test.com>',
'test@name <test@test.com>',
'"test\"name" <test@test.com>',
'test@test.com (test name)',
'test@test.com, test name <test@test.com>',
'Isto  um teste <test@test.com>',
'Isto =?iso-8859-1?q?=E9_um_teste?= <test@test.com>',
'"Isto  um teste" <test@test.com>',
"Isto =?iso-8859-1?q?=E9_um_teste?= \t=?iso-8859-1?q?_e_isto_=E9_outro_teste?=<test@test.com>",
'undisclosed-recipients:; (some comments)',
'mailing-list: test@test.com, test name <test@test.com>;, another test <another_test@test.com>',
"\\\\Escape in the beginning <test@test.com>",
"Escape in the\\\\middle <test@test.com>",
"Escape in the end\\\\ <test@test.com>",
$c count($addresses);
$a 0$a<$c; ++$a)
$parser->ParseAddressList($addresses[$a], $parsed))
'Address extraction error: '.$parser->error.' at position '.$parser->error_position."\n";
'Parsed address: '$addresses[$a], "\n";
$warning 0Reset($parser->warnings); $warning count($parser->warnings); Next($parser->warnings), $warning++)
$w Key($parser->warnings);
'Warning: '$parser->warnings[$w], ' at position '$w"\n";