|
imap_rfc822_parse_adrlist
Parses an address string
(PHP 4, PHP 5)
Example 1061. imap_rfc822_parse_adrlist() example<?php The above example will output: # 0 Code Examples / Notes » imap_rfc822_parse_adrlistian eiloart
This function does NOT test the syntax of either the local part, or the host part, it will permit illegal characters on either side. Note that 'host' refers to the email domain, not actually to any host. The at domain list is an obsolete addressing method which was available for routing email. RFC2822 says that it must be accepted, but should be ignored in routing. Note that if an address doesn't contain a personal part, or an "at domain list", that part of the array will be missing. Although RFC2822 permits consecutive comma separators in a list of email addresses, this function does not. That's probably a bug. In the following list of examples, #4 uses an "at domain list", #5 and after are illegal domains, but only the last actually generates an error. $adds = 'ian eiloart <iane@example.ac.uk>, shuf6@example.ac.uk, blobby, "ian,eiloart"<ian@example.ac.uk>, <@example.com:foo@example.ac.uk>, foo@#, ian@-example.com, ian@one@two'; $add_arr = imap_rfc822_parse_adrlist($adds, 'example.com'); var_export ($add_arr); array ( 0 => class stdClass { var $mailbox = 'iane'; var $host = 'example.ac.uk'; var $personal = 'ian eiloart'; }, 1 => class stdClass { var $mailbox = 'shuf6'; var $host = 'example.ac.uk'; }, 2 => class stdClass { var $mailbox = 'blobby'; var $host = 'example.ac.uk'; }, 3 => class stdClass { var $mailbox = 'ian'; var $host = 'example.ac.uk'; var $personal = 'ian,eiloart'; }, 4 => class stdClass { var $mailbox = 'foo'; var $host = 'example.ac.uk'; var $adl = '@example.com'; }, 5 => class stdClass { var $mailbox = 'foo'; var $host = '#'; }, 6 => class stdClass { var $mailbox = 'ian'; var $host = '-example.com'; }, 7 => class stdClass { var $mailbox = 'ian'; var $host = 'one'; }, 8 => class stdClass { var $mailbox = 'UNEXPECTED_DATA_AFTER_ADDRESS'; var $host = '.SYNTAX-ERROR.'; }, ) rainer perske
Invalid addresses, if detected, set host to '.SYNTAX-ERROR.'; but not all invalid addresses get detected as such, e.g. <.@host.do.main> is considered valid though a single dot is not a valid local part without using quotation marks. |
Change Languageimap_8bit imap_alerts imap_append imap_base64 imap_binary imap_body imap_bodystruct imap_check imap_clearflag_full imap_close imap_createmailbox imap_delete imap_deletemailbox imap_errors imap_expunge imap_fetch_overview imap_fetchbody imap_fetchheader imap_fetchstructure imap_get_quota imap_get_quotaroot imap_getacl imap_getmailboxes imap_getsubscribed imap_header imap_headerinfo imap_headers imap_last_error imap_list imap_listmailbox imap_listscan imap_listsubscribed imap_lsub imap_mail_compose imap_mail_copy imap_mail_move imap_mail imap_mailboxmsginfo imap_mime_header_decode imap_msgno imap_num_msg imap_num_recent imap_open imap_ping imap_qprint imap_renamemailbox imap_reopen imap_rfc822_parse_adrlist imap_rfc822_parse_headers imap_rfc822_write_address imap_savebody imap_scanmailbox imap_search imap_set_quota imap_setacl imap_setflag_full imap_sort imap_status imap_subscribe imap_thread imap_timeout imap_uid imap_undelete imap_unsubscribe imap_utf7_decode imap_utf7_encode imap_utf8 |