Mailgun: A email service for developer


Mailgun a powerful Apis that enable you to send receive and track email effortlessly.
Sdk available for different languages for more details like pricing and other checkout Mailgun website.

sdk of mailgun is available for different languages example codes on different languages are given below.

  • Curl

    curl -s --user 'api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0' \ \
    -F from='Excited User <>' \
    -F to='' \
    -F subject='Hello' \
    -F text='Testing some Mailgun awesomeness!'
  • Ruby

    def send_simple_message "https://api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0"\
    :from => "Excited User <>",
    :to => "",
    :subject => "Hello",
    :text => "Testing some Mailgun awesomeness!"
  • Python

    def send_simple_message():
    auth=("api", "key-3ax6xnjp29jd6fds4gc373sgvjxteol0"),
    data={"from": "Excited User <>",
    "to": [""],
    "subject": "Hello",
    "text": "Testing some Mailgun awesomeness!"})
  • Php

    # Include the Autoloader (see "Libraries" for install instructions)
    require 'vendor/autoload.php';
    use Mailgun\Mailgun;
    # Instantiate the client.
    $mgClient = new Mailgun('key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
    $domain = "";
    # Make the call to the client.
    $result = $mgClient->sendMessage("$domain",
    array(  'from'    => 'Excited User <>',
            'to'      => 'Mailgun Devs <>',
            'subject' => 'Hello',
            'text'    => 'Testing some Mailgun awesomeness!')
  • Java

    # Try running this locally.
    public static ClientResponse SendSimpleMessage() {
        Client client = Client.create();
        client.addFilter(new HTTPBasicAuthFilter(
        WebResource webResource = client.resource(
        MultivaluedMapImpl formData = new MultivaluedMapImpl();
        formData.add("from", "Excited User <>");
        formData.add("to", "");
        formData.add("subject", "Hello");
        formData.add("text", "Testing some Mailgun awesomeness!");
        return webResource.type(MediaType.APPLICATION_FORM_URLENCODED).
        post(ClientResponse.class, formData);
  • C#

    # Try running this locally.
    public static RestResponse SendSimpleMessage() {
        RestClient client = new RestClient();
        client.BaseUrl = "";
        client.Authenticator = new HttpBasicAuthenticator(
        RestRequest request = new RestRequest();
        "", ParameterType.UrlSegment);
        request.Resource = "{domain}/messages";
        request.AddParameter("from", "Excited User <>");
        request.AddParameter("to", "");
        request.AddParameter("subject", "Hello");
        request.AddParameter("text", "Testing some Mailgun awesomeness!");
        request.Method = Method.POST;
        return client.Execute(request);
    }supported languages are

Installing Mailgun on Ubuntu

# Install Composer
curl -sS | php

# Add Mailgun as a dependency (x.x is the SDK version, see Github README below)
php composer.phar require mailgun/mailgun-php:~x.x


6 thoughts on “Mailgun: A email service for developer

  • September 26, 2016 at 1:27 pm

    Great post. I used to be checking continuously this blog and I’m
    inspired! Extremely helpful information specially the ultimate part 🙂 I care for such info a lot.

    I used to be seeking this particular information for a long time.
    Thank you and best of luck.

    • September 26, 2016 at 1:56 pm

      Thanks buddy, i always try to write whatever i learn. will try best to update my blog on daily basis.

  • September 27, 2016 at 5:32 am

    Oh my goodness! Amazing article dude! Thanks, However I am having troubles with your RSS.
    I don’t understand the reason why I can’t subscribe to it.
    Is there anyone else having the same RSS problems?
    Anyone that knows the solution can you kindly respond?

    • September 27, 2016 at 6:57 am

      Hi i just try with my chrome extention it is working fine please try with it.

  • October 6, 2016 at 4:26 am

    After looking into a number of the blog posts on your
    website, I honestly like your technique of blogging.

    I bookmarked it to my bookmark website list and will be checking back
    soon. Please visit my website as well and let me know
    your opinion.


Leave a Reply

Your email address will not be published. Required fields are marked *