Validate/EmailAddress.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Validate  
Version
$Id$  

\Zend_Validate_EmailAddress

Package: Zend_Validate
Parent(s)
\Zend_Validate_Abstract
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  INVALID = 'emailAddressInvalid'
>VConstant  INVALID_FORMAT = 'emailAddressInvalidFormat'
>VConstant  INVALID_HOSTNAME = 'emailAddressInvalidHostname'
>VConstant  INVALID_MX_RECORD = 'emailAddressInvalidMxRecord'
>VConstant  INVALID_SEGMENT = 'emailAddressInvalidSegment'
>VConstant  DOT_ATOM = 'emailAddressDotAtom'
>VConstant  QUOTED_STRING = 'emailAddressQuotedString'
>VConstant  INVALID_LOCAL_PART = 'emailAddressInvalidLocalPart'
>VConstant  LENGTH_EXCEEDED = 'emailAddressLengthExceeded'

Properties

>VPropertyprotectedstring $_hostname
Details
Type
string
>VPropertyprotectedarray $_invalidIp = array('0' => '0.0.0.0/8', '10' => '10.0.0.0/8', '100' => '100.64.0.0/10', '127' => '127.0.0.0/8', '169' => '169.254.0.0/16', '172' => '172.16.0.0/12', '192' => array('192.0.0.0/24', '192.0.2.0/24', '192.88.99.0/24', '192.168.0.0/16'), '198' => '198.18.0.0/15', '224' => '224.0.0.0/4', '240' => '240.0.0.0/4')
As of RFC5753 (JAN 2010), the following blocks are no logner reserved: - 128.0.0.0/16 - 191.255.0.0/16 - 223.255.255.0/24
Default valuearray('0' => '0.0.0.0/8', '10' => '10.0.0.0/8', '100' => '100.64.0.0/10', '127' => '127.0.0.0/8', '169' => '169.254.0.0/16', '172' => '172.16.0.0/12', '192' => array('192.0.0.0/24', '192.0.2.0/24', '192.88.99.0/24', '192.168.0.0/16'), '198' => '198.18.0.0/15', '224' => '224.0.0.0/4', '240' => '240.0.0.0/4')Details
Type
array
See
As of RFC6598 (APR 2012), the following blocks are now reserved: - 100.64.0.0/10  
See
 
See
 
>VPropertyprotectedstring $_localPart
Details
Type
string
>VPropertyprotectedarray $_messageTemplates = array(self::INVALID => "Invalid type given. String expected", self::INVALID_FORMAT => "'%value%' is not a valid email address in the basic format local-part@hostname", self::INVALID_HOSTNAME => "'%hostname%' is not a valid hostname for email address '%value%'", self::INVALID_MX_RECORD => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'", self::INVALID_SEGMENT => "'%hostname%' is not in a routable network segment. The email address '%value%' should not be resolved from public network", self::DOT_ATOM => "'%localPart%' can not be matched against dot-atom format", self::QUOTED_STRING => "'%localPart%' can not be matched against quoted-string format", self::INVALID_LOCAL_PART => "'%localPart%' is not a valid local part for email address '%value%'", self::LENGTH_EXCEEDED => "'%value%' exceeds the allowed length")
Default valuearray(self::INVALID => "Invalid type given. String expected", self::INVALID_FORMAT => "'%value%' is not a valid email address in the basic format local-part@hostname", self::INVALID_HOSTNAME => "'%hostname%' is not a valid hostname for email address '%value%'", self::INVALID_MX_RECORD => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'", self::INVALID_SEGMENT => "'%hostname%' is not in a routable network segment. The email address '%value%' should not be resolved from public network", self::DOT_ATOM => "'%localPart%' can not be matched against dot-atom format", self::QUOTED_STRING => "'%localPart%' can not be matched against quoted-string format", self::INVALID_LOCAL_PART => "'%localPart%' is not a valid local part for email address '%value%'", self::LENGTH_EXCEEDED => "'%value%' exceeds the allowed length")Details
Type
array
>VPropertyprotectedarray $_messageVariables = array('hostname' => '_hostname', 'localPart' => '_localPart')
Default valuearray('hostname' => '_hostname', 'localPart' => '_localPart')Details
Type
array
>VPropertyprotected$_options = array('mx' => false, 'deep' => false, 'domain' => true, 'allow' => \Zend_Validate_Hostname::ALLOW_DNS, 'hostname' => null)
Internal options array
Default valuearray('mx' => false, 'deep' => false, 'domain' => true, 'allow' => \Zend_Validate_Hostname::ALLOW_DNS, 'hostname' => null)Details
Type
n/a

Methods

methodpublic__construct(array | \Zend_Config $options = array()) : void

Instantiates hostname validator for local use

The following option keys are supported: 'hostname' => A hostname validator, see Zend_Validate_Hostname 'allow' => Options for the hostname validator, see Zend_Validate_Hostname::ALLOW_* 'mx' => If MX check should be enabled, boolean 'deep' => If a deep MX check should be done, boolean
Parameters
NameTypeDescription
$optionsarray | \Zend_Config

OPTIONAL

methodprivate_isReserved(string $host) : boolean

Returns if the given host is reserved

Parameters
NameTypeDescription
$hoststring
Returns
TypeDescription
boolean
methodprivate_toIp(string $binary) : mixed

Converts a binary string to an IP address

Parameters
NameTypeDescription
$binarystring
Returns
TypeDescription
mixed
methodprivate_validateHostnamePart() : boolean

Internal method to validate the hostname part of the email address

Returns
TypeDescription
boolean
methodprivate_validateLocalPart() : boolean

Internal method to validate the local part of the email address

Returns
TypeDescription
boolean
methodprivate_validateMXRecords() : boolean

Internal method to validate the servers MX records

Returns
TypeDescription
boolean
methodpublicgetDeepMxCheck() : boolean

Returns the set deepMxCheck option

Returns
TypeDescription
boolean
methodpublicgetDomainCheck() : \unknown

Returns the set domainCheck option

Returns
TypeDescription
\unknown
methodpublicgetHostnameValidator() : \Zend_Validate_Hostname

Returns the set hostname validator

Returns
TypeDescription
\Zend_Validate_Hostname
methodpublicgetOptions() : array

Returns all set Options

Returns
TypeDescription
array
methodpublicgetValidateMx() : boolean

Returns the set validateMx option

Returns
TypeDescription
boolean
methodpublicisValid(string $value) : boolean

Defined by Zend_Validate_Interface

Returns true if and only if $value is a valid email address according to RFC2822
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
boolean
Details
Link
RFC2822  
Link
US-ASCII characters  
methodpublicsetDeepMxCheck(boolean $deep) : \Zend_Validate_EmailAddress

Set whether we check MX record should be a deep validation

Parameters
NameTypeDescription
$deepboolean

Set deep to true to perform a deep validation process for MX records

Returns
TypeDescription
\Zend_Validate_EmailAddressFluid Interface
methodpublicsetDomainCheck(boolean $domain = true) : \Zend_Validate_EmailAddress

Sets if the domain should also be checked or only the local part of the email address

Parameters
NameTypeDescription
$domainboolean
Returns
TypeDescription
\Zend_Validate_EmailAddressFluid Interface
methodpublicsetHostnameValidator(\Zend_Validate_Hostname $hostnameValidator = null, int $allow = \Zend_Validate_Hostname::ALLOW_DNS) : void

Parameters
NameTypeDescription
$hostnameValidator\Zend_Validate_Hostname

OPTIONAL

$allowint

OPTIONAL

methodpublicsetMessage(string $messageString, string $messageKey = null) : \Zend_Validate_Abstract

Sets the validation failure message template for a particular key Adds the ability to set messages to the attached hostname validator

Parameters
NameTypeDescription
$messageStringstring
$messageKeystring

OPTIONAL

Returns
TypeDescription
\Zend_Validate_AbstractProvides a fluent interface
Throws
ExceptionDescription
\Zend_Validate_Exception
methodpublicsetOptions(array $options = array()) : \Zend_Validate_EmailAddress

Set options for the email validator

Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Validate_EmailAddressfluid interface
methodpublicsetValidateMx(boolean $mx) : \Zend_Validate_EmailAddress

Set whether we check for a valid MX record via DNS

This only applies when DNS hostnames are validated
Parameters
NameTypeDescription
$mxboolean

Set allowed to true to validate for MX records, and false to not validate them

Returns
TypeDescription
\Zend_Validate_EmailAddressFluid Interface
methodpublicvalidateMxSupported() : boolean

Whether MX checking via getmxrr is supported or not

This currently only works on UNIX systems
Returns
TypeDescription
boolean
Documentation was generated by phpDocumentor 2.2.0 .