Email Validation

This API endpoint is an email address validation service. Given an arbitrary address, we will validate the address based on:

  • Syntax checks (RFC defined grammar)
  • DNS validation
  • Spell checks
  • Email Service Provider (ESP) specific local-part grammar (if available).

Mailgun’s email validation service is available for free to all Mailgun customers. It is intended to validate email addresses submitted through forms like newsletters, online registrations and shopping carts. It is not intended to be used for bulk email list scrubbing and we reserve the right to disable your account if we see it being used as such.

Note

No addresses submitted to this service are ever stored on any Mailgun servers. The parser runs completely in memory and no address is persisted after the request is complete.

Warning

Do not use your Mailgun private API key. Instead, use your Mailgun public key, available in the My Account tab of the Control Panel.

GET /address/validate

Given an arbitrary address, validates address based off defined checks.

Parameter Description
address An email address to validate. (Maximum: 512 characters)
api_key If you can not use HTTP Basic Authentication (preferred), you can pass your api_key in as a parameter.
GET /address/parse

Parses a delimiter separated list of email addresses into two lists: parsed addresses and unparsable portions. The parsed addresses are a list of addresses that are syntactically valid (and optionally have DNS and ESP specific grammar checks) the unparsable list is a list of characters sequences that the parser was not able to understand. These often align with invalid email addresses, but not always. Delimiter characters are comma (,) and semicolon (;).

Parameter Description
addresses A delimiter separated list of addresses. (Maximum: 8000 characters)
syntax_only Perform only syntax checks or DNS and ESP specific validation as well. (true by default)
api_key If you can not use HTTP Basic Authentication (preferred), you can pass your api_key in as a parameter.

Example

Validate a single email address.

curl -G --user 'api:pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7' -G \
    https://api.mailgun.net/v2/address/validate \
    --data-urlencode address='foo@mailgun.net'
public static ClientResponse GetValidate() {
       Client client = new Client();
       client.addFilter(new HTTPBasicAuthFilter("api",
                       "pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7"));
       WebResource webResource =
               client.resource("https://api.mailgun.net/v2" +
                               "/address/validate");
       MultivaluedMapImpl queryParams = new MultivaluedMapImpl();
       queryParams.add("address", "foo@mailgun.net");
       return webResource.queryParams(queryParams).get(ClientResponse.class);
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7');
$validateAddress = 'foo@mailgun.net';

# Issue the call to the client.
$result = $mgClient->get("address/validate", array('address' => $validateAddress));
def get_validate():
    return requests.get(
        "https://api.mailgun.net/v2/address/validate",
        auth=("api", "pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7"),
        params={"address": "foo@mailgun.net"})
def get_validate
  url_params = Multimap.new
  url_params[:address] = "foo@mailgun.net"
  query_string = url_params.collect {|k, v| "#{k.to_s}=#{CGI::escape(v.to_s)}"}.
    join("&")
  RestClient.get "https://api:pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7"\
  "@api.mailgun.net/v2/address/validate?#{query_string}"
end
public static IRestResponse GetValidate() {
       RestClient client = new RestClient();
       client.BaseUrl = "https://api.mailgun.net/v2";
       client.Authenticator =
               new HttpBasicAuthenticator("api",
                                          "pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7");
       RestRequest request = new RestRequest();
       request.Resource = "/address/validate";
       request.AddParameter("address", "foo@mailgun.net");
       return client.Execute(request);
}

Sample response:

    {
        "is_valid": true,
        "address": "foo@mailgun.net",
        "parts": {
            "display_name": ""
            "local_part": "foo",
            "domain": "mailgun.net",
        },
        "did_you_mean": null
}

Parse a list of email addresses.

curl -G --user 'api:pubkey-501jygdalut926-6mb1ozo8ay9crlc28' \
    https://api.mailgun.net/v2/address/parse \
    --data-urlencode addresses='Alice <alice@example.com>,bob@example.com,example.com'
public static ClientResponse GetParse() {
       Client client = new Client();
       client.addFilter(new HTTPBasicAuthFilter("api",
                       "pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7"));
       WebResource webResource =
               client.resource("https://api.mailgun.net/v2" +
                               "/address/parse");
       MultivaluedMapImpl queryParams = new MultivaluedMapImpl();
       queryParams.add("addresses", "Alice <alice@example.com>,bob@example.com,example.com");
       return webResource.queryParams(queryParams).get(ClientResponse.class);
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7');
$domain = 'samples.mailgun.org';
$addressList = 'Alice <alice@example.com>,bob@example.com,example.com';

# Issue the call to the client.
$result = $mgClient->get("address/parse", array('addresses' => $addressList));
def get_parse():
    return requests.get(
        "https://api.mailgun.net/v2/address/parse",
        auth=("api", "pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7"),
        params={"addresses": "Alice <alice@example.com>,bob@example.com,example.com"})
def get_parse
  url_params = Multimap.new
  url_params[:addresses] = "Alice <alice@example.com>,bob@example.com,example.com"
  query_string = url_params.collect {|k, v| "#{k.to_s}=#{CGI::escape(v.to_s)}"}.
    join("&")
  RestClient.get "https://api:pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7"\
  "@api.mailgun.net/v2/address/parse?#{query_string}"
end
public static IRestResponse GetParse() {
       RestClient client = new RestClient();
       client.BaseUrl = "https://api.mailgun.net/v2";
       client.Authenticator =
               new HttpBasicAuthenticator("api",
                                          "pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7");
       RestRequest request = new RestRequest();
       request.Resource = "/address/parse";
       request.AddParameter("addresses", "Alice <alice@example.com>,bob@example.com,example.com");
       return client.Execute(request);
}

Sample response:

    {
    "parsed": [
        "Alice <alice@example.com>",
        "bob@example.com"
    ],
    "unparseable": [
        "example.com"
    ]
}