Skip to main content

Crate utopia_emails

Crate utopia_emails 

Source
Expand description

Email addresses: split at the @, checked, made canonical per mail provider, and their domains classified as free or disposable.

PHPRust
Utopia\Emails\EmailEmail
new Email($email)Email::new
get(), getLocal(), getDomain()Email::get, Email::local, Email::domain
isValid(), hasValidLocal()Email::is_valid, Email::has_valid_local
hasValidDomain()Email::has_valid_domain_syntax, then the domain’s known suffix (utopia-domains)
isDisposable(), isFree()Lists::is_disposable, Lists::is_on_free_list (isFree() also needs it not disposable)
getCanonical(), isCanonicalSupported(), getCanonicalDomain()Email::canonical, Email::is_canonical_supported, Email::canonical_domain
Email::LOCAL_MAX_LENGTH, DOMAIN_MAX_LENGTHLOCAL_MAX_LENGTH, DOMAIN_MAX_LENGTH
data/free-domains.php, data/disposable-domains.phpLists (Lists::FREE, Lists::DISPOSABLE)
Canonicals\Providers\{Gmail, Outlook, Yahoo, Icloud, Protonmail, Fastmail, Walla, Generic}Provider (PROVIDERS, Provider::GENERIC)

What Email asks of its domain (getProvider(), getSubdomain(), isKnown()) is Utopia\Domains\Domain’s, which the extension calls as PHP does, so this crate does not parse domains.

The lists are embedded in the crate (data/*-domains.txt, exported from the PHP package’s data/*-domains.php by data/export.php) with hash tables of their lines built at compile time (build.rs), so a lookup allocates nothing and both live in the library’s read-only pages, shared by every process. The PHP validators, providers and import task are not ported: Email is.

Structs§

Canonical
The canonical form of an address: its local part and domain with a provider’s aliases removed.
DomainList
A set of domains, matched as PHP’s in_array($domain, $list): a loose comparison, so numeric strings compare as numbers ("1e3" matches an entry "1000").
Email
An address: trimmed, lower-cased (mb_strtolower) and split at its single @. It can hold any bytes, as a PHP string does.
Lists
The free and disposable domain lists.
Provider
A mail provider’s aliasing rules.

Enums§

Error
Why an address could not be parsed or made canonical.

Constants§

DOMAIN_MAX_LENGTH
The most characters allowed after the @.
LOCAL_MAX_LENGTH
The most characters allowed before the @.

Statics§

PROVIDERS
The providers Email consults, in order.