The Official Go SDK, Available Now

GoLang MascotToday, we're happy to announce the general availability of our Mailgun-Go SDK. Now you can send messages through Mailgun using Go! Mailgun-Go allows you to easily interact with our API by greatly reducing the amount of boiler-plate code you need to maintain.

Our SDK is built from a simple foundation graciously offered by Michael Banzon on Github. We are truly indebted to him for his support. We added features on top of his own SDK, including significantly enhanced API coverage, and a rich set of acceptance tests to help developers get started and better understand how to use the SDK.

Mailgun-Go lets you send messages to mailing lists of arbitrary size, subject only to the limitations of your Mailgun account. Here's a simple example where we send one message to three recipients:

mg := mailgun.NewMailgun("example.com", "key-example", "")

m := mg.NewMessage(  
    "Dwight Schrute <dwight@example.com>",        // From
    "The Printer Caught Fire",                    // Subject
    "We have a problem.",                         // Plain-text body
    "Michael Scott <michael@example.com>",        // Recipients (vararg list)
    "George Schrute <george@example.com>",
    "it-support@example.com",
)

_, _, err := mg.Send(m)

if err != nil {  
  log.Fatal(err)
}

and here's one where we send the same message to potentially millions of recipients:

mg := mailgun.NewMailgun("example.com", "key-example", "")

m := mg.NewMessage(  
    "Dwight Schrute <dwight@example.com>",                // From
    "Help!",                                              // Subject
    "The printer's on fire on floor %recipient.floor%!!"  // Plain-text body
)

// Iterate over a collection of addresses and per-user variables.
for _, user := range mailingList {  
    err := m.AddRecipientAndVariables(user.address, map[string]interface{}{
        "floor": user.floor,
    })
    if err != nil {
      log.Fatal(err)
    }
}

_, _, err = mg.Send(m)

if err != nil {  
  log.Fatal(err)
}

As you can see, the Mailgun-Go SDK provides an interface that scales pleasantly with your needs.

We will be updating our online documentation to include Go examples soon. In the meantime, please feel free to consult our documentation on GoDoc, read the acceptance tests in our Github repository, or open a new issue through Github or your control panel. We'll be happy to answer any questions you have!

Happy emailing,
The Mailgunners

comments powered by Disqus

Mailgun Get posts by email

Like what you're reading? Get these posts delivered to your inbox.

No spam, ever.