View source code
Display the source code in std/net/isemail.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
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.

Function std.net.isemail.isEmail

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

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

Distinguishes 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.

Note

The DNS check is currently not implemented.

Parameters

NameDescription
email The email address to check
checkDNS If Yes.checkDns 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 <[email protected]>, Jacob Carlborg

License

Boost Software License 1.0 Dominic Sayers graciously granted permission to use the Boost license via email on Feb 22, 2011.