Mailing Lists

You can programmatically create mailing lists using Mailgun Mailing List API. A mailing list is a group of members (recipients) which itself has an email address, like developers@mailgun.net. This address becomes an ID for this mailing list.

When you send a message to developers@mailgun.net, all members of the list will receive a copy of it.

GET /lists/pages

Paginate over mailing lists under your account

Parameter Description
limit Maximum number of records to return (optional: 100 by default)
GET /lists/<address>

Returns a single mailing list by a given address.

POST /lists

Creates a new mailing list.

Parameter Description
address A valid email address for the mailing list, e.g. developers@mailgun.net, or Developers <devs@mg.net>
name Mailing list name, e.g. Developers (optional)
description A description (optional)
access_level List access level, one of: readonly (default), members, everyone
PUT /lists/<address>

Update mailing list properties, such as address, description or name

Parameter Description
address New mailing list address, e.g. devs@mg.net (optional)
name New name, e.g. My newsletter (optional)
description Description string (optional)
access_level List access level, one of: readonly (default), members, everyone
DELETE /lists/<address>

Deletes a mailing list.

GET /lists/<address>/members/pages

Paginate over list members in the given mailing list

Parameter Description
subscribed yes to lists subscribed, no for unsubscribed. list all if not set
limit Maximum number of records to return (optional: 100 by default)
GET /lists/<address>/members/<member_address>

Retrieves a mailing list member.

POST /lists/<address>/members

Adds a member to the mailing list.

Parameter Description
address Valid email address specification, e.g. Alice <alice@example.com> or just alice@example.com
name Optional member name
vars JSON-encoded dictionary string with arbitrary parameters, e.g. {"gender":"female","age":27}
subscribed yes to add as subscribed (default), no as unsubscribed
upsert
yes to update member if present, no to
raise error in case of a duplicate member (default)
PUT /lists/<address>/members/<member_address>

Updates a mailing list member with given properties. Won’t touch the property if it’s not passed in.

Parameter Description
address Valid email address specification, e.g. Alice <alice@example.com> or just alice@example.com
name Recipient name, e.g. Alice
vars JSON-encoded dictionary string with arbitrary parameters, e.g. {"gender":"female","age":27}
subscribed no to set unsubscribed, yes as subscribed
POST /lists/<address>/members.json

Adds multiple members, up to 1,000 per call, to a Mailing List.

Parameter Description
members JSON-encoded array. Elements can be either addresses, e.g. ["bob@example.com", "alice@example.com"], or JSON objects, e.g. [{"address": "bob@example.com", "name": "Bob", "subscribed": false}, {"address": "alice@example.com", "name": "Alice"}] . Custom variables can be provided, see examples.
upsert yes to update existing members, no (default) to ignore duplicates
DELETE /lists/<address>/members/<member_address>

Delete a mailing list member.

Access Levels

Mailing lists have three different access levels. These levels define how users can interact with the list.

Access Level Description
read-only Only authenticated users can post to this list. It is used for mass announcements and newsletters. This is the default access level.
members Subscribed members of the list can communicate with each other.
everyone Everyone can post to this list. Recommended turning spam filtering on when using this mode.

Examples

Create a mailing list:

curl -s --user 'api:YOUR_API_KEY' \
    https://api.mailgun.net/v3/lists \
    -F address='LIST@YOUR_DOMAIN_NAME' \
    -F description='Mailgun developers list'
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public class MGSample {

    // ...

    public static ClientResponse CreateMailingList() {

        Client client = ClientBuilder.newClient();
        client.register(HttpAuthenticationFeature.basic(
            "api",
            "YOUR_API_KEY"
        ));

        WebTarget mgRoot = client.target("https://api.mailgun.net/v3");

        Form reqData = new Form();
        reqData.param("address", "LIST@YOUR_DOMAIN_NAME");
        reqData.param("description", "LIST_DESCRIPTION");

        return mgRoot
            .path("/lists")
            .request(MediaType.APPLICATION_FORM_URLENCODED)
            .buildPost(Entity.entity(reqData, MediaType.APPLICATION_FORM_URLENCODED))
            .invoke(ClientResponse.class);
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');

# Issue the call to the client.
$result = $mgClient->post("lists", array(
    'address'     => 'LIST@YOUR_DOMAIN_NAME',
    'description' => 'Mailgun Dev List'
));
def create_mailing_list():
    return requests.post(
        "https://api.mailgun.net/v3/lists",
        auth=('api', 'YOUR_API_KEY'),
        data={'address': 'LIST@YOUR_DOMAIN_NAME',
              'description': "Mailgun developers list"})
def create_mailing_list
  RestClient.post("https://api:YOUR_API_KEY" \
                  "@api.mailgun.net/v3/lists",
                  :address => 'LIST@YOUR_DOMAIN_NAME',
                  :description => "Mailgun developers list")
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class CreateMailingListChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (CreateMailingList ().Content.ToString ());
    }

    public static IRestResponse CreateMailingList ()
    {

        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "lists";
        request.AddParameter ("address", "LIST@YOUR_DOMAIN_NAME");
        request.AddParameter ("description", "Mailgun developers list");
        request.Method = Method.POST;
        return client.Execute (request);
    }

}
func CreateMailingList(domain, apiKey string) (mailgun.List, error) {
  mg := mailgun.NewMailgun(domain, apiKey, "")
  protoList := mailgun.List{
    Address:     "LIST@YOUR_DOMAIN_NAME",
    Name:        "dev",
    Description: "Mailgun developers list.",
    AccessLevel: mailgun.Members,
  }
  return mg.CreateList(protoList)
}

Sample response:

{
  "message": "Mailing list has been created",
  "list": {
      "created_at": "Tue, 06 Mar 2012 05:44:45 GMT",
      "address": "dev@samples.mailgun.org",
      "members_count": 0,
      "description": "Mailgun developers list",
      "name": ""
  }
}

Get a page of mailing lists:

curl -s --user 'api:YOUR_API_KEY' -G \
    https://api.mailgun.net/v3/lists/pages
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public class MGSample {

    // ...

    public static ClientResponse GetMailingLists() {

        Client client = ClientBuilder.newClient();
        client.register(HttpAuthenticationFeature.basic(
            "api",
            "YOUR_API_KEY"
        ));

        WebTarget mgRoot = client.target("https://api.mailgun.net/v3");

        return mgRoot
            .path("/lists/pages")
            .request()
            .buildGet()
            .invoke(ClientResponse.class);
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');

# Issue the call to the client.
$result = $mgClient->get("lists/pages", array(
    'limit'      =>  5
));
def list_members():
    return requests.get(
        "https://api.mailgun.net/v3/lists/pages",
        auth=('api', 'YOUR_API_KEY'))
def list_members
  RestClient.get("https://api:YOUR_API_KEY" \
                 "@api.mailgun.net/v3/lists/pages")
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class GetMailingListsChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (GetMailingLists ().Content.ToString ());
    }

    public static IRestResponse GetMailingLists ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "lists/pages";
        return client.Execute (request);
    }

}
// Coming soon

Sample response:

{
  "items": [
    {
      "access_level": "everyone",
      "address": "dev@samples.mailgun.org",
      "created_at": "Tue, 06 Mar 2012 05:44:45 GMT",
      "description": "Mailgun developers list",
      "members_count": 1,
      "name": ""
    },
    {
      "access_level": "readonly",
      "address": "bar@example.com",
      "created_at": "Wed, 06 Mar 2013 11:39:51 GMT",
      "description": "",
      "members_count": 2,
      "name": ""
    }
  ],
  "paging": {
    "first": "https://url_to_next_page",
    "last": "https://url_to_last_page",
    "next": "https://url_to_next_page",
    "previous": "https://url_to_previous_page"
  }
}

Add a mailing list member:

curl -s --user 'api:YOUR_API_KEY' \
    https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members \
    -F subscribed=True \
    -F address='bar@example.com' \
    -F name='Bob Bar' \
    -F description='Developer' \
    -F vars='{"age": 26}'
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public class MGSample {

    // ...

    public static ClientResponse AddListMember() {

        Client client = ClientBuilder.newClient();
        client.register(HttpAuthenticationFeature.basic(
            "api",
            "YOUR_API_KEY"
        ));

        WebTarget mgRoot = client.target("https://api.mailgun.net/v3");

        Form reqData = new Form();
        reqData.param("address", "bob@example.com");
        reqData.param("subscribed", "true");
        reqData.param("name", "Bob Bar");
        reqData.param("description", "developer");
        reqData.param("vars", "{\"age\": 26}");

        return mgRoot
            .path("/lists/{list}@{domain}/members")
            .resolveTemplate("list", "YOUR_LIST_NAME")
            .resolveTemplate("domain", "YOUR_DOMAIN_NAME")
            .request(MediaType.APPLICATION_FORM_URLENCODED)
            .buildPost(Entity.entity(reqData, MediaType.APPLICATION_FORM_URLENCODED))
            .invoke(ClientResponse.class);
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$listAddress = 'LIST@YOUR_DOMAIN_NAME';

# Issue the call to the client.
$result = $mgClient->post("lists/$listAddress/members", array(
    'address'     => 'bar@example.com',
    'name'        => 'Bob Bar',
    'description' => 'Developer',
    'subscribed'  => true,
    'vars'        => '{"age": 26}'
));
def add_list_member():
    return requests.post(
        "https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members",
        auth=('api', 'YOUR_API_KEY'),
        data={'subscribed': True,
              'address': 'bar@example.com',
              'name': 'Bob Bar',
              'description': 'Developer',
              'vars': '{"age": 26}'})
def add_list_member
  RestClient.post("https://api:YOUR_API_KEY" \
                  "@api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members",
                  :subscribed => true,
                  :address => 'bar@example.com',
                  :name => 'Bob Bar',
                  :description => 'Developer',
                  :vars => '{"age": 26}')
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class AddListMemberChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (AddListMember ().Content.ToString ());
    }

    public static IRestResponse AddListMember ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "lists/{list}/members";
        request.AddParameter ("list", "LIST@YOUR_DOMAIN_NAME",
                              ParameterType.UrlSegment);
        request.AddParameter ("address", "bar@example.com");
        request.AddParameter ("subscribed", true);
        request.AddParameter ("name", "Bob Bar");
        request.AddParameter ("description", "Developer");
        request.AddParameter ("vars", "{\"age\": 26}");
        request.Method = Method.POST;
        return client.Execute (request);
    }

}
func AddListMember(domain, apiKey string) error {
  mg := mailgun.NewMailgun(domain, apiKey, "")
  memberJoe := mailgun.Member{
    Address:    "joe@example.com",
    Name:       "Joe Example",
    Subscribed: mailgun.Subscribed,
  }
  return mg.CreateMember(true, "mailingList@example.com", memberJoe)
}

Sample response:

{
  "member": {
      "vars": {
          "age": 26
      },
      "name": "Bob Bar",
      "subscribed": true,
      "address": "bar@example.com"
  },
  "message": "Mailing list member has been created"
}

Add multiple mailing list members (limit 1,000 per call):

curl -s --user 'api:YOUR_API_KEY' \
    https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members.json \
    -F upsert=true \
    -F members='[{"address": "Alice <alice@example.com>", "vars": {"age": 26}},{"name": "Bob", "address": "bob@example.com", "vars": {"age": 34}}]'
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public class MGSample {

    // ...

    public static ClientResponse AddListMembers() {

        Client client = ClientBuilder.newClient();
        client.register(HttpAuthenticationFeature.basic(
            "api",
            "YOUR_API_KEY"
        ));

        WebTarget mgRoot = client.target("https://api.mailgun.net/v3");

        Form reqData = new Form();
        reqData.param("members", "[{\"address\": \"Alice <alice@example.com>\", \"vars\": {\"age\": 26}},{\"name\": \"Bob\", \"address\": \"bob@example.com\", \"vars\": {\"age\": 34}}]");

        return mgRoot
            .path("/lists/{list}@{domain}/members.json")
            .resolveTemplate("list", "YOUR_LIST_NAME")
            .resolveTemplate("domain", "YOUR_DOMAIN_NAME")
            .request(MediaType.APPLICATION_FORM_URLENCODED)
            .buildPost(Entity.entity(reqData, MediaType.APPLICATION_FORM_URLENCODED))
            .invoke(ClientResponse.class);
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$listAddress = 'LIST@YOUR_DOMAIN_NAME';

# Issue the call to the client.
$result = $mgClient->post("lists/$listAddress/members.json", array(
    'members'    => '[{"address": "Alice <alice@example.com>", "vars": {"age": 26}}, {"name": "Alice", "address": "alice@example.com", "vars": {"age": 34}}]',
    'upsert' => true
));
def add_list_member():
    return requests.post(
        "https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members.json",
        auth=('api', 'YOUR_API_KEY'),
        data={'upsert': True,
              'members': '[{"address": "Alice <alice@example.com>", "vars": {"age": 26}},{"name": "Bob", "address": "bob@example.com", "vars": {"age": 34}}]')
def add_list_member
  RestClient.post("https://api:YOUR_API_KEY" \
                  "@api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members.json",
                  :upsert => true,
                  :members => '[{"address": "Alice <alice@example.com>", "vars": {"age": 26}},{"name": "Bob", "address": "bob@example.com", "vars": {"age": 34}}]')
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class AddListMembersChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (AddListMembers ().Content.ToString ());
    }

    public static IRestResponse AddListMembers ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "lists/{list}/members.json";
        request.AddParameter ("list", "LIST@YOUR_DOMAIN_NAME",
                              ParameterType.UrlSegment);
        request.AddParameter ("members",
                              "[{\"address\":\"Alice<alice@example.com>\",\"vars\":{\"age\":26}},{\"name\":\"Bob\",\"address\":\"bob@example.com\",\"vars\":{\"age\":34}}]");
        request.AddParameter ("upsert", true);
        request.Method = Method.POST;
        return client.Execute (request);
    }

}
func AddListMembers(domain, apiKey string) error {
  mg := mailgun.NewMailgun(domain, apiKey, "")
  return mg.CreateMemberList(nil, "LIST@YOUR_DOMAIN_NAME", []interface{}{
    mailgun.Member{
      Address:    "alice@example.com",
      Name:       "Alice's debugging account",
      Subscribed: mailgun.Unsubscribed,
    },
    mailgun.Member{
      Address:    "Bob Cool <bob@example.com>",
      Name:       "Bob's Cool Account",
      Subscribed: mailgun.Subscribed,
    },
    mailgun.Member{
      Address: "joe.hamradio@example.com",
      // Charlette is a ham radio packet BBS user.
      // We attach her packet BBS e-mail address as an arbitrary var here.
      Vars: map[string]interface{}{
        "packet-email": "KW9ABC @ BOGUS-4.#NCA.CA.USA.NOAM",
      },
    },
  })
}

Sample response:

{
  "message": "Mailing list has been updated",
  "list": {
    "members_count": 7,
    "description": "My updated test mailing list",
    "created_at": "Wed, 06 Mar 2013 11:39:51 GMT",
    "access_level": "readonly",
    "address": "dev@samples.mailgun.org",
    "name": "Test List Updated"
  }
}

You can also update an existing member:

curl -s --user 'api:YOUR_API_KEY' -X PUT \
    https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members/bar@example.com \
    -F subscribed=False \
    -F name='Foo Bar'
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public class MGSample {

    // ...

    public static ClientResponse UpdateMailingListMember() {

        Client client = ClientBuilder.newClient();
        client.register(HttpAuthenticationFeature.basic(
            "api",
            "YOUR_API_KEY"
        ));

        WebTarget mgRoot = client.target("https://api.mailgun.net/v3");

        Form reqData = new Form();
        reqData.param("subscribed", "false");
        reqData.param("name", "Alice Doe");

        return mgRoot
            .path("/lists/{list_name}@{domain}/members/{address}")
            .resolveTemplate("domain", "YOUR_DOMAIN_NAME")
            .resolveTemplate("list_name", "YOUR_MAILING_LIST_NAME")
            .resolveTemplate("address", "alice@example.com")
            .request(MediaType.APPLICATION_FORM_URLENCODED)
            .buildPut(Entity.entity(reqData, MediaType.APPLICATION_FORM_URLENCODED))
            .invoke(ClientResponse.class);
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$listAddress = 'LIST@YOUR_DOMAIN_NAME';
$memberAddress = 'bob@example.com';

# Issue the call to the client.
$result = $mgClient->put("lists/$listAddress/members/$memberAddress", http_build_query(array(
    'subscribed' => false,
    'name'       => 'Foo Bar'
)));
def update_member():
    return requests.put(
        ("https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members"
         "/bar@example.com"),
        auth=('api', 'YOUR_API_KEY'),
        data={'subscribed': False,
              'name': 'Foo Bar'})
def update_member
  RestClient.put("https://api:YOUR_API_KEY" \
                 "@api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members" \
                 "/bar@example.com",
                 :subscribed => false,
                 :name => 'Foo Bar')
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class UpdateListMemberChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (UpdateListMember ().Content.ToString ());
    }

    public static IRestResponse UpdateListMember ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "lists/{list}/members/{member}";
        request.AddParameter ("list", "LIST@YOUR_DOMAIN_NAME",
                              ParameterType.UrlSegment);
        request.AddParameter ("member", "bar@example.com",
                              ParameterType.UrlSegment);
        request.AddParameter ("subscribed", false);
        request.AddParameter ("name", "Foo Bar");
        request.Method = Method.PUT;
        return client.Execute (request);
    }

}
func UpdateMember(domain, apiKey string) error {
  mg := mailgun.NewMailgun(domain, apiKey, "")
  _, err = mg.UpdateMember("bar@example.com", "LIST@YOUR_DOMAIN_NAME", mailgun.Member{
    Name: "Foo Bar",
    Subscribed: mailgun.Unsubscribed,
  })
  return err
}

Sample response:

{
  "member": {
      "vars": {
          "age": 26
      },
      "name": "Foo Bar",
      "subscribed": false,
      "address": "bar@example.com"
  },
  "message": "Mailing list member has been updated"
}

Listing members:

curl -s --user 'api:YOUR_API_KEY' -G \
    https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members/pages
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public class MGSample {

    // ...

    public static ClientResponse GetListMembers() {

        Client client = ClientBuilder.newClient();
        client.register(HttpAuthenticationFeature.basic(
            "api",
            "YOUR_API_KEY"
        ));

        WebTarget mgRoot = client.target("https://api.mailgun.net/v3");

        return mgRoot
            .path("/lists/{list_name}@{domain}/members/pages")
            .resolveTemplate("domain", "YOUR_DOMAIN_NAME")
            .resolveTemplate("list_name", "YOUR_MAILING_LIST_NAME")
            .request()
            .buildGet()
            .invoke(ClientResponse.class);
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$listAddress = 'LIST@YOUR_DOMAIN_NAME';

# Issue the call to the client.
$result = $mgClient->get("lists/$listAddress/members/pages", array(
    'subscribed' => 'yes',
    'limit'      =>  5
));
def list_members():
    return requests.get(
        "https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members/pages",
        auth=('api', 'YOUR_API_KEY'))
def list_members
  RestClient.get("https://api:YOUR_API_KEY" \
                 "@api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members/pages")
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class GetListMembersChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (GetListMembers ().Content.ToString ());
    }

    public static IRestResponse GetListMembers ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "lists/{list}/members/pages";
        request.AddParameter ("list", "LIST@YOUR_DOMAIN_NAME",
                              ParameterType.UrlSegment);
        return client.Execute (request);
    }

}
func GetMembers(domain, apiKey string) (int, []mailgun.Member, error) {
  mg := mailgun.NewMailgun(domain, apiKey, "")
  return mg.GetMembers(-1, -1, mailgun.All, "LIST@YOUR_DOMAIN_NAME")
}

Sample response:

{
  "items": [
      {
          "vars": {
              "age": 26
          },
          "name": "Foo Bar",
          "subscribed": false,
          "address": "bar@example.com"
      }
  ],
  "paging": {
    "first": "https://url_to_first_page",
    "last": "https://url_to_last_page",
    "next": "http://url_to_next_page",
    "previous": "http://url_to_previous_page"
  }
}

Remove a member:

curl -s --user 'api:YOUR_API_KEY' -X DELETE \
    https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members/bar@example.com
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public class MGSample {

    // ...

    public static ClientResponse RemoveListMember() {

        Client client = ClientBuilder.newClient();
        client.register(HttpAuthenticationFeature.basic(
            "api",
            "YOUR_API_KEY"
        ));

        WebTarget mgRoot = client.target("https://api.mailgun.net/v3");

        return mgRoot
            .path("/lists/{list_name}@{domain}/members/{address}")
            .resolveTemplate("domain", "YOUR_DOMAIN_NAME")
            .resolveTemplate("list_name", "YOUR_MAILING_LIST_NAME")
            .resolveTemplate("address", "bob@example.com")
            .request()
            .buildDelete()
            .invoke(ClientResponse.class);
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$listAddress = 'LIST@YOUR_DOMAIN_NAME';
$listMember = 'bar@example.com';

# Issue the call to the client.
$result = $mgClient->delete("lists/$listAddress/members/$listMember");
def remove_member():
    return requests.delete(
        ("https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members"
         "/bar@example.com"),
        auth=('api', 'YOUR_API_KEY'))
def remove_member
  RestClient.delete("https://api:YOUR_API_KEY" \
                    "@api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME/members" \
                    "/bar@example.com")
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class RemoveListMemberChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (RemoveListMember ().Content.ToString ());
    }

    public static IRestResponse RemoveListMember ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "lists/{list}/members/{member}";
        request.AddParameter ("list", "LIST@YOUR_DOMAIN_NAME",
                              ParameterType.UrlSegment);
        request.AddParameter ("member", "bar@example.com",
                              ParameterType.UrlSegment);
        request.Method = Method.DELETE;
        return client.Execute (request);
    }

}
func DeleteListMember(domain, apiKey string) error {
  mg := mailgun.NewMailgun(domain, apiKey, "")
  return mg.DeleteMember("joe@example.com", "LIST@YOUR_DOMAIN_NAME")
}

Sample response:

{
  "member": {
      "address": "bar@example.com"
  },
  "message": "Mailing list member has been deleted"
}

Remove mailing list:

curl -s --user 'api:YOUR_API_KEY' -X DELETE \
    https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;

import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;

public class MGSample {

    // ...

    public static ClientResponse RemoveMailingList() {

        Client client = ClientBuilder.newClient();
        client.register(HttpAuthenticationFeature.basic(
            "api",
            "YOUR_API_KEY"
        ));

        WebTarget mgRoot = client.target("https://api.mailgun.net/v3");

        return mgRoot
            .path("/lists/{list_name}@{domain}")
            .resolveTemplate("domain", "YOUR_DOMAIN_NAME")
            .resolveTemplate("list_name", "YOUR_MAILING_LIST_NAME")
            .request()
            .buildDelete()
            .invoke(ClientResponse.class);
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$listAddress = 'LIST@YOUR_DOMAIN_NAME';

# Issue the call to the client.
$result = $mgClient->delete("lists/$listAddress");
def remove_list():
    return requests.delete(
        "https://api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME",
        auth=('api', 'YOUR_API_KEY'))
def remove_list
  RestClient.delete("https://api:YOUR_API_KEY" \
                    "@api.mailgun.net/v3/lists/LIST@YOUR_DOMAIN_NAME")
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class RemoveMailingListChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (RemoveMailingList ().Content.ToString ());
    }

    public static IRestResponse RemoveMailingList ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "lists/{list}";
        request.AddParameter ("list", "LIST@YOUR_DOMAIN_NAME",
                              ParameterType.UrlSegment);
        request.Method = Method.DELETE;
        return client.Execute (request);
    }

}
func DeleteList(domain, apiKey string) error {
  mg := mailgun.NewMailgun(domain, apiKey, "")
  return mg.DeleteList("LIST@YOUR_DOMAIN_NAME")
}

Sample response:

{
  "message": "Mailing list has been deleted",
  "address": "dev@samples.mailgun.org"
}