Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 11-Nov-2020 | - | ||||
LICENSE | H A D | 11-Nov-2020 | 1.5 KiB | 28 | 22 | |
Makefile | H A D | 11-Nov-2020 | 158 | 10 | 7 | |
README.md | H A D | 11-Nov-2020 | 2.1 KiB | 70 | 53 | |
bounces.go | H A D | 11-Nov-2020 | 4 KiB | 129 | 81 | |
campaigns.go | H A D | 11-Nov-2020 | 2.8 KiB | 80 | 60 | |
credentials.go | H A D | 11-Nov-2020 | 2.4 KiB | 80 | 66 | |
domains.go | H A D | 11-Nov-2020 | 4.4 KiB | 125 | 86 | |
email_validation.go | H A D | 11-Nov-2020 | 3.1 KiB | 78 | 45 | |
enums.go | H A D | 11-Nov-2020 | 6.1 KiB | 337 | 269 | |
events.go | H A D | 11-Nov-2020 | 13.1 KiB | 446 | 303 | |
httphelpers.go | H A D | 11-Nov-2020 | 6.1 KiB | 287 | 233 | |
mailgun.go | H A D | 11-Nov-2020 | 14.3 KiB | 369 | 211 | |
mailing_lists.go | H A D | 11-Nov-2020 | 10.7 KiB | 322 | 243 | |
messages.go | H A D | 11-Nov-2020 | 22.8 KiB | 722 | 470 | |
recipients.go | H A D | 11-Nov-2020 | 803 | 43 | 32 | |
rest_shim.go | H A D | 11-Nov-2020 | 5.3 KiB | 163 | 114 | |
routes.go | H A D | 11-Nov-2020 | 5.1 KiB | 139 | 98 | |
spam_complaints.go | H A D | 11-Nov-2020 | 2.6 KiB | 82 | 57 | |
stats.go | H A D | 11-Nov-2020 | 3.5 KiB | 142 | 113 | |
tags.go | H A D | 11-Nov-2020 | 4.2 KiB | 178 | 133 | |
unsubscribes.go | H A D | 11-Nov-2020 | 2.9 KiB | 82 | 63 | |
webhooks.go | H A D | 11-Nov-2020 | 2.8 KiB | 96 | 80 |
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