View source code Display the source code in std/net/isemail.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

Function std.net.isemail.isEmail

Check that an email address conforms to RFCs 5321, 5322 and others.

As of Version 3.0, we are now distinguishing clearly between a Mailbox as defined by RFC 5321 and an addr-spec as defined by RFC 5322. Depending on the context, either can be regarded as a valid email address. The RFC 5321 Mailbox specification is more restrictive (comments, white space and obsolete forms are not allowed).

Prototype

EmailStatus isEmail(Char)(
  const(Char)[] email,
  CheckDns checkDNS = CheckDns.no,
  EmailStatusCode errorLevel = EmailStatusCode.none
)
if (isSomeChar!Char);

Note

The DNS check is currently not implemented.

Parameters

NameDescription
email The email address to check
checkDNS If CheckDns.yes then a DNS check for MX records will be made
errorLevel Determines the boundary between valid and invalid addresses. Status codes above this number will be returned as-is, status codes below will be returned as EmailStatusCode.valid. Thus the calling program can simply look for EmailStatusCode.valid if it is only interested in whether an address is valid or not. The errorLevel will determine how "picky" isEmail() is about the address. If omitted or passed as EmailStatusCode.none then isEmail() will not perform any finer grained error checking and an address is either considered valid or not. Email status code will either be EmailStatusCode.valid or EmailStatusCode.error.

Returns

an EmailStatus, indicating the status of the email address.

Authors

Dominic Sayers , Jacob Carlborg

License

Boost Software License 1.0

Comments