hanayo/vendor/gopkg.in/mailgun/mailgun-go.v1
2019-02-23 13:29:15 +00:00
..
cmd/mailgun replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
.gitignore replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
.travis.yml replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
acceptance_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
bounces_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
bounces.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
campaigns.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
credentials_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
credentials.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
domains_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
domains.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
email_validation_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
email_validation.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
events_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
events.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
examples_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
httphelpers.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
LICENSE replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
mailgun_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
mailgun.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
mailing_lists_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
mailing_lists.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
Makefile replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
messages_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
messages.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
README.md replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
rest_shim.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
routes_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
routes.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
spam_complaints_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
spam_complaints.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
stats_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
stats.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
tags_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
tags.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
unsubscribes_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
unsubscribes.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
webhooks_test.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00
webhooks.go replace zxq.co/ripple/hanayo 2019-02-23 13:29:15 +00:00

Mailgun with Go

Build Status GoDoc

Go library for interacting with the Mailgun API.

Sending mail via the mailgun CLI

Export your API keys and domain

$ export MG_API_KEY=your-api-key
$ export MG_DOMAIN=your-domain
$ export MG_PUBLIC_API_KEY=your-public-key
$ export MG_URL="https://api.mailgun.net/v3"

Send an email

$ echo -n 'Hello World' | mailgun send -s "Test subject" address@example.com

Sending mail via the golang library

package main

import "gopkg.in/mailgun/mailgun-go.v1"

mg := mailgun.NewMailgun(yourdomain, ApiKey, publicApiKey)
message := mailgun.NewMessage(
    "sender@example.com",
    "Fancy subject!",
    "Hello from Mailgun Go!",
    "recipient@example.com")
resp, id, err := mg.Send(message)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("ID: %s Resp: %s\n", id, resp)

Installation

Install the go library

go get gopkg.in/mailgun/mailgun-go.v1

Install the mailgun CLI

go install github.com/mailgun/mailgun-go/cmd/mailgun/./...

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_PUBLIC_API_KEY is the public API key - you can get this value from the Mailgun admin interface.
  • MG_API_KEY is the (private) API key - you can get this value from the Mailgun admin interface.
  • 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.