DomainFromEmailAddress static method

String DomainFromEmailAddress(
  1. String emailAddress
)
Gets the domain name from an email address. The email address.

Implementation

static String DomainFromEmailAddress(String emailAddress) {
  List<String> emailAddressParts = emailAddress.split('@');

  if (emailAddressParts.length != 2 ||
      StringUtils.IsNullOrEmpty(emailAddressParts[1])) {
    throw new FormatException("Strings.InvalidEmailAddress");
  }

  return emailAddressParts[1];
}