• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..11-Nov-2020-

LICENSEH A D11-Nov-20201.5 KiB2822

MakefileH A D11-Nov-2020158 107

README.mdH A D11-Nov-20202.1 KiB7053

bounces.goH A D11-Nov-20204 KiB12981

campaigns.goH A D11-Nov-20202.8 KiB8060

credentials.goH A D11-Nov-20202.4 KiB8066

domains.goH A D11-Nov-20204.4 KiB12586

email_validation.goH A D11-Nov-20203.1 KiB7845

enums.goH A D11-Nov-20206.1 KiB337269

events.goH A D11-Nov-202013.1 KiB446303

httphelpers.goH A D11-Nov-20206.1 KiB287233

mailgun.goH A D11-Nov-202014.3 KiB369211

mailing_lists.goH A D11-Nov-202010.7 KiB322243

messages.goH A D11-Nov-202022.8 KiB722470

recipients.goH A D11-Nov-2020803 4332

rest_shim.goH A D11-Nov-20205.3 KiB163114

routes.goH A D11-Nov-20205.1 KiB13998

spam_complaints.goH A D11-Nov-20202.6 KiB8257

stats.goH A D11-Nov-20203.5 KiB142113

tags.goH A D11-Nov-20204.2 KiB178133

unsubscribes.goH A D11-Nov-20202.9 KiB8263

webhooks.goH A D11-Nov-20202.8 KiB9680

README.md

1Mailgun with Go
2===============
3
4[![Build Status](https://img.shields.io/travis/mailgun/mailgun-go/master.svg)](https://travis-ci.org/mailgun/mailgun-go)
5[![GoDoc](https://godoc.org/gopkg.in/mailgun/mailgun-go.v1?status.svg)](https://godoc.org/gopkg.in/mailgun/mailgun-go.v1)
6
7
8Go library for interacting with the [Mailgun](https://mailgun.com/) [API](https://documentation.mailgun.com/api_reference.html).
9
10# Sending mail via the mailgun CLI
11Export your API keys and domain
12```bash
13$ export MG_API_KEY=your-api-key
14$ export MG_DOMAIN=your-domain
15$ export MG_PUBLIC_API_KEY=your-public-key
16$ export MG_URL="https://api.mailgun.net/v3"
17```
18Send an email
19```bash
20$ echo -n 'Hello World' | mailgun send -s "Test subject" address@example.com
21```
22
23# Sending mail via the golang library
24```go
25package main
26
27import "gopkg.in/mailgun/mailgun-go.v1"
28
29mg := mailgun.NewMailgun(yourdomain, ApiKey, publicApiKey)
30message := mailgun.NewMessage(
31    "sender@example.com",
32    "Fancy subject!",
33    "Hello from Mailgun Go!",
34    "recipient@example.com")
35resp, id, err := mg.Send(message)
36if err != nil {
37    log.Fatal(err)
38}
39fmt.Printf("ID: %s Resp: %s\n", id, resp)
40```
41
42# Installation
43Install the go library
44```
45go get gopkg.in/mailgun/mailgun-go.v1
46```
47
48Install the mailgun CLI
49```
50go install github.com/mailgun/mailgun-go/cmd/mailgun/./...
51```
52
53# Testing
54
55*WARNING* - running the tests will cost you money!
56
57To run the tests various environment variables must be set. These are:
58
59* `MG_DOMAIN` is the domain name - this is a value registered in the Mailgun admin interface.
60* `MG_PUBLIC_API_KEY` is the public API key - you can get this value from the Mailgun admin interface.
61* `MG_API_KEY` is the (private) API key - you can get this value from the Mailgun admin interface.
62* `MG_EMAIL_TO` is the email address used in various sending tests.
63
64and finally
65
66* `MG_SPEND_MONEY` if this value is set the part of the test that use the API to actually send email
67will be run - be aware *this will count on your quota* and *this _will_ cost you money*.
68
69The code is released under a 3-clause BSD license. See the LICENSE file for more information.
70