Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

mailgun-go

> 编程语言
Open source

Go library for the Mailgun API.

745 stars0 likes0 views
WebsiteGitHub

About

Go library for the Mailgun API.

Mailgun with Go

Go library for interacting with the Mailgun API.

Installation

If you are using Go Modules make sure you include the /v5 at the end of your import paths

bash
go get github.com/mailgun/mailgun-go/v5

Usage

Send a message

…

Get Events

…

Event Polling

The mailgun library has built-in support for polling the events api

…

Email Validations

…

Webhook Handling

…

Sending HTML templates

…

Using Templates

Templates enable you to create message templates on your Mailgun account and then populate the data variables at send-time. This allows you to have your layout and design managed on the server and handle the data on the client. The template variables are added as a JSON stringified X-Mailgun-Variables header. For example, if you have a template to send a password reset link, you could do the following:

…

The official mailgun documentation includes examples using this library. Go here.

EU Region

European customers will need to change the default API Base to access your domains

go
mg := mailgun.NewMailgun("MAILGUN_API_KEY")
mg.SetAPIBase(mailgun.APIBaseEU)

Major Version Migration Notes

We are trying to keep breaking changes to a minimum, but sometimes they are necessary.

We are guaranteeing that there will be no breaking changes within a major version.

v4 to v5 Migration

List of changes are in Release v5.0.0.

How to migrate

  1. Upgrade to the latest v4 release (v4.23.0) first.
  2. Get rid of all deprecated code usage. We recommend using staticcheck linter SA1019 check for that (or just look for // Deprecated: comments in the code) and follow the recommendations there. This should make the major version bump go more smoothly.
  3. Update your import paths to use /v5 at the end, e.g.
    go
    import "github.com/mailgun/mailgun-go/v5"

Testing

WARNING - running the tests will cost you money!

To run the tests various environment variables must be set. These are:

  • MG_DOMAIN is the domain name - this is a value registered in the Mailgun admin interface.
  • MG_API_KEY is the Private API key - you can get this value from the Mailgun security page
  • MG_EMAIL_TO is the email address used in various sending tests.

and finally

  • MG_SPEND_MONEY if this value is set the part of the test that use the API to actually send email will be run - be aware this will count on your quota and this will cost you money.

The code is released under a 3-clause BSD license. See the LICENSE file for more information.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Goemailgomailgun

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言