std.net.isemail
Validates an email address according to RFCs 5321, 5322 and others.
Copyright
Dominic Sayers, Jacob Carlborg 2008-.
Test schema documentation: Copyright © 2011, Daniel Marschall
License
Boost Software License 1.0
Dominic Sayers graciously granted permission to use the Boost license via email on Feb 22, 2011.
Version
3.0.13 - Version 3.0 of the original PHP implementation: http://www.dominicsayers.com/isemail
Standards
- RFC 5321
- RFC 5322
References:
- http://www.dominicsayers.com/isemail
- http://tools.ietf.org/html/rfc5321
- http://tools.ietf.org/html/rfc5322
Source: std/net/isemail.d
alias CheckDns
Types 6
Flag for indicating if the isEmail function should perform a DNS check or not.
If set to CheckDns.no, isEmail does not perform DNS checking.
Otherwise if set to CheckDns.yes, isEmail performs DNS checking.
structEmailStatus
Represents the status of an email address
Methods
bool valid() @property const @safe @nogc pure nothrow scopeReturns: If the email address is valid or not.string localPart() @property const @safe @nogc pure nothrow return scopeReturns: The local part of the email address, that is, the part before the @ sign.string domainPart() @property const @safe @nogc pure nothrow return scopeReturns: The domain part of the email address, that is, the part after the @ sign.EmailStatusCode statusCode() @property const @safe @nogc pure nothrow scopeReturns: The email status codestring status() @property const @safe @nogc pure nothrow scopeReturns: A describing string of the status codeConstructors
this(bool valid, string localPart, string domainPart, EmailStatusCode statusCode)Self aliases to a `bool` representing if the email is valid or notenumEmailStatusCode
An email status code, indicating if an email address is valid or not. If it is invalid it also indicates why.
validCategory = 1Address is valid
dnsWarning = 7Address is valid but a DNS check was not successful
rfc5321 = 15Address is valid for SMTP but has unusual elements
cFoldingWhitespace = 31Address is valid within the message but cannot be used unmodified for the envelope
deprecated_ = 63Address contains deprecated elements but may still be valid in restricted contexts
rfc5322 = 127The address is only valid according to the broad definition of RFC 5322. It is otherwise invalid
any = 252All finer grained error checking is turned on. Address containing errors or warnings is considered invalid. A specific email status code will be returned indicating the error/warning of the address.
none = 253Address is either considered valid or not, no finer grained error checking is performed. Returned email status code will be either Error or Valid.
warning = 254Address containing warnings is considered valid, that is, any status code below 16 is considered valid.
error = 255Address is invalid for any purpose
valid = 0Address is valid
dnsWarningNoMXRecord = 5Could not find an MX record for this domain but an A-record does exist
dnsWarningNoRecord = 6Could not find an MX record or an A-record for this domain
rfc5321TopLevelDomain = 9Address is valid but at a Top Level Domain
rfc5321TopLevelDomainNumeric = 10Address is valid but the Top Level Domain begins with a number
rfc5321QuotedString = 11Address is valid but contains a quoted string
rfc5321AddressLiteral = 12Address is valid but at a literal address not a domain
rfc5321IpV6Deprecated = 13Address is valid but contains a :: that only elides one zero group
comment = 17Address contains comments
foldingWhitespace = 18Address contains Folding White Space
deprecatedLocalPart = 33The local part is in a deprecated form
deprecatedFoldingWhitespace = 34Address contains an obsolete form of Folding White Space
deprecatedQuotedText = 35A quoted string contains a deprecated character
deprecatedQuotedPair = 36A quoted pair contains a deprecated character
deprecatedComment = 37Address contains a comment in a position that is deprecated
deprecatedCommentText = 38A comment contains a deprecated character
deprecatedCommentFoldingWhitespaceNearAt = 49Address contains a comment or Folding White Space around the @ sign
rfc5322Domain = 65Address is RFC 5322 compliant but contains domain characters that are not allowed by DNS
rfc5322TooLong = 66Address is too long
rfc5322LocalTooLong = 67The local part of the address is too long
rfc5322DomainTooLong = 68The domain part is too long
rfc5322LabelTooLong = 69The domain part contains an element that is too long
rfc5322DomainLiteral = 70The domain literal is not a valid RFC 5321 address literal
rfc5322DomainLiteralObsoleteText = 71The domain literal is not a valid RFC 5321 address literal and it contains obsolete characters
rfc5322IpV6GroupCount = 72The IPv6 literal address contains the wrong number of groups
rfc5322IpV6TooManyDoubleColons = 73The IPv6 literal address contains too many :: sequences
rfc5322IpV6BadChar = 74The IPv6 address contains an illegal group of characters
rfc5322IpV6MaxGroups = 75The IPv6 address has too many groups
rfc5322IpV6ColonStart = 76IPv6 address starts with a single colon
rfc5322IpV6ColonEnd = 77IPv6 address ends with a single colon
errorExpectingDomainText = 129A domain literal contains a character that is not allowed
errorNoLocalPart = 130Address has no local part
errorNoDomain = 131Address has no domain part
errorConsecutiveDots = 132The address may not contain consecutive dots
errorTextAfterCommentFoldingWhitespace = 133Address contains text after a comment or Folding White Space
errorTextAfterQuotedString = 134Address contains text after a quoted string
errorTextAfterDomainLiteral = 135Extra characters were found after the end of the domain literal
errorExpectingQuotedPair = 136The address contains a character that is not allowed in a quoted pair
errorExpectingText = 137Address contains a character that is not allowed
errorExpectingQuotedText = 138A quoted string contains a character that is not allowed
errorExpectingCommentText = 139A comment contains a character that is not allowed
errorBackslashEnd = 140The address cannot end with a backslash
errorDotStart = 141Neither part of the address may begin with a dot
errorDotEnd = 142Neither part of the address may end with a dot
errorDomainHyphenStart = 143A domain or subdomain cannot begin with a hyphen
errorDomainHyphenEnd = 144A domain or subdomain cannot end with a hyphen
errorUnclosedQuotedString = 145Unclosed quoted string
errorUnclosedComment = 146Unclosed comment
errorUnclosedDomainLiteral = 147Domain literal is missing its closing bracket
errorFoldingWhitespaceCrflX2 = 148Folding White Space contains consecutive CRLF sequences
errorFoldingWhitespaceCrLfEnd = 149Folding White Space ends with a CRLF sequence
errorCrNoLf = 150Address contains a carriage return that is not followed by a line feed
enumEmailPart
componentLocalPart
componentDomain
componentLiteral
contextComment
contextFoldingWhitespace
contextQuotedString
contextQuotedPair
status
structTokenImpl(Char)
enumAsciiToken
horizontalTab = 9
unitSeparator = 31
delete_ = 127
Functions 7
fn
EmailStatus isEmail(Char)(const(Char)[] email, CheckDns checkDNS = No.checkDns,
EmailStatusCode errorLevel = EmailStatusCode.none) if (isSomeChar!(Char))Check that an email address conforms to RFCs 5321, 5322 and others.fn
string statusCodeDescription(EmailStatusCode statusCode) @safe @nogc pure nothrowParams: statusCode = The EmailStatusCode to read Returns: A detailed string describing the given status codefn
int compareFirstN(alias pred = "a < b", S1, S2)(S1 s1, S2 s2, size_t length) if (is(immutable ElementType!(S1) == immutable dchar) && is(immutable ElementType!(S2) == immutable dchar))fn
ElementType!(A) pop(A)(ref A a) if (isDynamicArray!(A) && !isNarrowString!(A) && isMutable!(A) && !is(A == void[]))fn
const(T)[] get(T)(const(T)[] str, size_t index, dchar c)fn
bool isUpToFourHexChars(Char)(scope const(Char)[] s)