百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

mailgun-go

> 编程语言
开源

用于 Mailgun API 的 Go 库。

745 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于 Mailgun API 的 Go 库。

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

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

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.
    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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Goemailgomailgun

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

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