# README
Mailgun with Go
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" [email protected]
Sending mail via the golang library
package main
import "gopkg.in/mailgun/mailgun-go.v1"
mg := mailgun.NewMailgun(yourdomain, ApiKey, publicApiKey)
message := mailgun.NewMessage(
"[email protected]",
"Fancy subject!",
"Hello from Mailgun Go!",
"[email protected]")
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.
# Packages
No description provided by the author
# Functions
Extract the http status code from error object.
NewMailGun creates a new client instance.
Return a new Mailgun client using the environment variables MG_API_KEY, MG_DOMAIN, MG_PUBLIC_API_KEY and MG_URL.
NewMessage returns a new e-mail message with the simplest envelop needed to send.
NewMIMEMessage creates a new MIME message.
Creates a new cursor from a taglist.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DefaultLimit and DefaultSkip instruct the SDK to rely on Mailgun's reasonable defaults for Paging settings.
DefaultLimit and DefaultSkip instruct the SDK to rely on Mailgun's reasonable defaults for Paging settings.
Disabled, Tag, and Delete indicate spam actions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Disabled, Tag, and Delete indicate spam actions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
A mailing list may have one of three membership modes.
The MailgunGoUserAgent identifies the client to the server, for logging purposes.
MaxNumberOfRecipients represents the largest batch of recipients that Mailgun can support in a single API call.
A mailing list may have one of three membership modes.
No description provided by the author
No description provided by the author
No description provided by the author
A mailing list may have one of three membership modes.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Disabled, Tag, and Delete indicate spam actions.
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
Mailing list members have an attribute that determines if they've subscribed to the mailing list or not.
No description provided by the author
ErrEmptyParam results occur when a required parameter is missing.
Mailing list members have an attribute that determines if they've subscribed to the mailing list or not.
Mailing list members have an attribute that determines if they've subscribed to the mailing list or not.
# Structs
No description provided by the author
No description provided by the author
Bounce aggregates data relating to undeliverable messages to a specific intended recipient, identified by Address.
Campaigns have been deprecated since development work on this SDK commenced.
No description provided by the author
Complaint structures track how many times one of your emails have been marked as spam.
A Credential structure describes a principle allowed to send or receive mail at the domain.
No description provided by the author
No description provided by the author
DNSRecord structures describe intended records to properly configure your domain for use with Mailgun.
A Domain structure holds information about a domain used when sending mail.
EmailVerification records basic facts about a validated e-mail address.
The EmailVerificationParts structure breaks out the basic elements of an email address.
No description provided by the author
No description provided by the author
No description provided by the author
EventIterator maintains the state necessary for paging though small parcels of a larger set of events.
No description provided by the author
EventPoller maintains the state necessary for polling events.
GetEventsOptions lets the caller of GetEvents() specify how the results are to be returned.
No description provided by the author
No description provided by the author
Depreciated See `ListEvents()`.
A List structure provides information for a mailing list.
MailgunImpl bundles data needed by a large number of methods in order to interact with the Mailgun API.
A Member structure represents a member of the mailing list.
Message structures contain both the message text and the envelop for an e-mail message.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
A Route structure contains information on a configured or to-be-configured route.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StoredAttachment structures contain information on an attachment associated with a stored message.
StoredMessage structures contain the (parsed) message content for an email sent to a Mailgun account.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
This error will be returned whenever a Mailgun API returns an error response.
No description provided by the author
# Interfaces
Mailgun defines the supported subset of the Mailgun API.
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author