Constants

ATEXT

ATEXT

Valid atext characters.

ENCODE_FILTER

ENCODE_FILTER

Excluded (in ASCII decimal): 0-8, 10-31, 34, 40-41, 44, 58-60, 62, 64, 91-93, 127

Properties

$_data

$_data : string

The address string to parse.

Type

string

$_datalen

$_datalen : integer

Length of the address string.

Type

integer

$_comments

$_comments : string

Comment cache.

Type

string

$_listob

$_listob : \Horde_Mail_Rfc822_List

List object to return in parseAddressList().

Type

\Horde_Mail_Rfc822_List

$_params

$_params : array

Configuration parameters.

Type

array

$_ptr

$_ptr : integer

Data pointer.

Type

integer

Methods

parseAddressList()

parseAddressList(mixed  $address, array  $params = array()) : \Horde_Mail_Rfc822_List

Starts the whole process.

Parameters

mixed $address

The address(es) to validate. Either a string, a Horde_Mail_Rfc822_Object, or an array of strings and/or Horde_Mail_Rfc822_Objects.

array $params

Optional parameters:

  • default_domain: (string) Default domain/host. DEFAULT: None
  • group: (boolean) Return a GroupList object instead of a List object? DEFAULT: false
  • limit: (integer) Stop processing after this many addresses. DEFAULT: No limit (0)
  • validate: (mixed) Strict validation of personal part data? If false, attempts to allow non-ASCII characters and non-quoted strings in the personal data, and will silently abort if an unparseable address is found. If true, does strict RFC 5322 (ASCII-only) parsing. If 'eai' (@since 2.5.0), allows RFC 6532 (EAI/UTF-8) addresses. DEFAULT: false

Throws

\Horde_Mail_Exception

Returns

\Horde_Mail_Rfc822_List

A list object.

encode()

encode(string  $str, string  $type = 'address') : string

Quotes and escapes the given string if necessary using rules contained in RFC 2822 [3.2.5].

Parameters

string $str

The string to be quoted and escaped.

string $type

Either 'address', 'comment' (@since 2.6.0), or 'personal'.

Returns

string —

The correctly quoted and escaped string.

trimAddress()

trimAddress(string  $address) : string

If an email address has no personal information, get rid of any angle brackets (<>) around it.

Parameters

string $address

The address to trim.

Returns

string —

The trimmed address.

approximateCount()

approximateCount(string  $data) : integer

Returns an approximate count of how many addresses are in the string.

This is APPROXIMATE as it only splits based on a comma which has no preceding backslash.

Parameters

string $data

Addresses to count.

Returns

integer —

Approximate count.

isValidInetAddress()

isValidInetAddress(string  $data, boolean  $strict = false) : mixed

Validates whether an email is of the common internet form: <user>@<domain>. This can be sufficient for most people.

Optional stricter mode can be utilized which restricts mailbox characters allowed to: alphanumeric, full stop, hyphen, and underscore.

Parameters

string $data

Address to check.

boolean $strict

Strict check?

Returns

mixed —

False if it fails, an indexed array username/domain if it matches.

_parseAddressList()

_parseAddressList() 

address-list = (address *("," address)) / obs-addr-list

_parseAddress()

_parseAddress() 

address = mailbox / group

_parseGroup()

_parseGroup() : boolean

group = display-name ":" [mailbox-list / CFWS] ";" [CFWS] display-name = phrase

Throws

\Horde_Mail_Exception

Returns

boolean —

True if a group was parsed.

_parseMailbox()

_parseMailbox() : mixed

mailbox = name-addr / addr-spec

Returns

mixed —

Mailbox object if mailbox was parsed, or false.

_parseNameAddr()

_parseNameAddr() : mixed

name-addr = [display-name] angle-addr display-name = phrase

Returns

mixed —

Mailbox object, or false.

_parseAddrSpec()

_parseAddrSpec() : mixed

addr-spec = local-part "@" domain

Throws

\Horde_Mail_Exception

Returns

mixed —

Mailbox object.

_parseLocalPart()

_parseLocalPart() : string

local-part = dot-atom / quoted-string / obs-local-part obs-local-part = word *("." word)

Throws

\Horde_Mail_Exception

Returns

string —

The local part.

_parseAngleAddr()

_parseAngleAddr() : mixed

"<" [ "@" route ":" ] local-part "@" domain ">"

Throws

\Horde_Mail_Exception

Returns

mixed —

Mailbox object, or false.

_parseDomainList()

_parseDomainList() : array

obs-domain-list = "@" domain *(*(CFWS / "," ) [CFWS] "@" domain)

Throws

\Horde_Mail_Exception

Returns

array —

Routes.

_rfc822ParsePhrase()

_rfc822ParsePhrase(  $phrase) 

phrase = 1*word / obs-phrase word = atom / quoted-string obs-phrase = word *(word / "." / CFWS)

Parameters

$phrase

Throws

\Horde_Mail_Exception

_rfc822ParseQuotedString()

_rfc822ParseQuotedString(  $str) 

Parameters

$str

Throws

\Horde_Mail_Exception

_rfc822ParseDotAtom()

_rfc822ParseDotAtom(  $str, string  $validate = null) 

dot-atom = [CFWS] dot-atom-text [CFWS] dot-atom-text = 1*atext *("." 1*atext)

atext = ; Any character except controls, SP, and specials.

For RFC-822 compatibility allow LWSP around '.'.

Parameters

$str
string $validate

Use these characters as delimiter.

Throws

\Horde_Mail_Exception

_rfc822ParseAtomOrDot()

_rfc822ParseAtomOrDot(  $str) 

atom = [CFWS] 1*atext [CFWS] atext = ; Any character except controls, SP, and specials.

This method doesn't just silently skip over WS.

Parameters

$str

Throws

\Horde_Mail_Exception

_rfc822ParseDomain()

_rfc822ParseDomain(  $str) 

domain = dot-atom / domain-literal / obs-domain domain-literal = [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS] obs-domain = atom *("." atom)

Parameters

$str

Throws

\Horde_Mail_Exception

_rfc822ParseDomainLiteral()

_rfc822ParseDomainLiteral(  $str) 

domain-literal = [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS] dcontent = dtext / quoted-pair dtext = NO-WS-CTL / ; Non white space controls %d33-90 / ; The rest of the US-ASCII %d94-126 ; characters not including "[", ; "]", or "\"

Parameters

$str

Throws

\Horde_Mail_Exception

_rfc822SkipLwsp()

_rfc822SkipLwsp(boolean  $advance = false) 

Parameters

boolean $advance

Advance cursor?

Throws

\Horde_Mail_Exception

_rfc822SkipComment()

_rfc822SkipComment() 

Throws

\Horde_Mail_Exception

_rfc822IsAtext()

_rfc822IsAtext(string  $chr, string  $validate = null) : boolean

Check if data is an atom.

Parameters

string $chr

The character to check.

string $validate

If in non-validate mode, use these characters as the non-atom delimiters.

Returns

boolean —

True if a valid atom.

_curr()

_curr(boolean  $advance = false) : string

Return current character.

Parameters

boolean $advance

If true, advance the cursor.

Returns

string —

The current character (false if EOF reached).