- Best Practices
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
Today, 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:
1mg := mailgun.NewMailgun("example.com", "key-example", "")23m := mg.NewMessage( 4 "Dwight Schrute <dwight@example.com>", // From5 "The Printer Caught Fire", // Subject6 "We have a problem.", // Plain-text body7 "Michael Scott <michael@example.com>", // Recipients (vararg list)8 "George Schrute <george@example.com>",9 "it-support@example.com",10)1112_, _, err := mg.Send(m)1314if err != nil { 15 log.Fatal(err)16}
and here’s one where we send the same message to potentially millions of recipients:
1mg := mailgun.NewMailgun("example.com", "key-example", "")23m := mg.NewMessage( 4 "Dwight Schrute <dwight@example.com>", // From5 "Help!", // Subject6 "The printer's on fire on floor %recipient.floor%!!" // Plain-text body7)89// Iterate over a collection of addresses and per-user variables.10for _, user := range mailingList { 11 err := m.AddRecipientAndVariables(user.address, map[string]interface{}{12 "floor": user.floor,13 })14 if err != nil {15 log.Fatal(err)16 }17}1819_, _, err = mg.Send(m)2021if err != nil { 22 log.Fatal(err)23}
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 Sending!
Learn about our Deliverability Services
Looking to send a high volume of emails? Our email experts can supercharge your email performance. See how we've helped companies like Lyft, Shopify, Github increase their email delivery rates to an average of 97%.
Last updated on August 28, 2020
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
How to Improve Holiday Supply Chain Communication with Email
What Is a RESTful API, How It Works, Advantages, and Examples
Email’s Not Dead Season 3 Is Finally Here
Easier and Faster Implementation with Our Updated SDKs
The Difference Between SMTP and API
The Basics of Email Dark Mode
COVID-19 Survey: How the Pandemic Has Affected Email Sending
The Top Email Clients and Email Apps of 2021
The Benefits of Email Automation
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Become an Email Pro With Our Templates API
Google Postmaster Tools: Understanding Sender Reputation
Navigating Your Career as a Woman in Tech
Implementing Dmarc – A Step-by-Step Guide
Email Bounces: What To Do About Them
Announcing InboxReady: The deliverability suite you need to hit the inbox
Black History Month in Tech: 7 Visionaries Who Shaped The Future
How To Create a Successful Triggered Email Program
Designing HTML Email Templates For Transactional Emails
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Implementing Dmarc – A Step-by-Step Guide
Announcing InboxReady: The deliverability suite you need to hit the inbox
Designing HTML Email Templates For Transactional Emails
Email Security Best Practices: How To Keep Your Email Program Safe
Mailgun’s Active Defense Against Log4j
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
Email's Best of 2021
5 Ideas For Better Developer-Designer Collaboration
Mailgun Joins Sinch: The Future of Customer Communications Is Here
Always be in the know and grab free email resources!
By sending this form, I agree that Mailgun may contact me and process my data in accordance with its Privacy Policy.