PHP Class JBZoo\Utils\Email

Show file Open project: jbzoo/utils Class Usage Examples

Public Methods

Method Description
check ( string | array $emails ) : array Check if email(s) is(are) valid. You can send one or an array of emails.
checkDns ( string $email ) : boolean Check for DNS MX records of the email domain. Notice that a (temporary) DNS error will have the same result as no records were found. Code coverage ignored because this method requires DNS requests that could not be reliable.
getDomain ( string | array $emails ) : array Get domains from email addresses. The not valid email addresses will be skipped.
getDomainSorted ( array $emails ) : array Get domains from email addresses in alphabetical order.
getGravatarBuiltInDefaultImage ( ) : string
getGravatarBuiltInImages ( ) : array
getGravatarUrl ( string $email, integer $size = 32, string $defaultImage = 'identicon' ) : null | string Generates an Gravatar URL.

Private Methods

Method Description
_extractDomain ( string $email ) : string
_handleEmailsInput ( string | array $emails ) : array Transforms strings in array, and remove duplicates.
_isValid ( string $email ) : boolean

Method Details

check() public static method

Check if email(s) is(are) valid. You can send one or an array of emails.
public static check ( string | array $emails ) : array
$emails string | array
return array

checkDns() public static method

Check for DNS MX records of the email domain. Notice that a (temporary) DNS error will have the same result as no records were found. Code coverage ignored because this method requires DNS requests that could not be reliable.
public static checkDns ( string $email ) : boolean
$email string
return boolean

getDomain() public static method

Get domains from email addresses. The not valid email addresses will be skipped.
public static getDomain ( string | array $emails ) : array
$emails string | array
return array

getDomainSorted() public static method

Get domains from email addresses in alphabetical order.
public static getDomainSorted ( array $emails ) : array
$emails array
return array

getGravatarBuiltInDefaultImage() public static method

public static getGravatarBuiltInDefaultImage ( ) : string
return string

getGravatarBuiltInImages() public static method

public static getGravatarBuiltInImages ( ) : array
return array

getGravatarUrl() public static method

Size of the image: * The default size is 32px, and it can be anywhere between 1px up to 2048px. * If requested any value above the allowed range, then the maximum is applied. * If requested any value bellow the minimum, then the default is applied. Default image: * It can be an URL to an image. * Or one of built in options that Gravatar has. See Email::getGravatarBuiltInImages(). * If none is defined then a built in default is used. See Email::getGravatarBuiltInDefaultImage().
public static getGravatarUrl ( string $email, integer $size = 32, string $defaultImage = 'identicon' ) : null | string
$email string
$size integer
$defaultImage string
return null | string