Giter Club home page Giter Club logo

mailgun-go's Introduction

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" [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.

mailgun-go's People

Contributors

b0d0nne11 avatar brynbellomy avatar c2h5oh avatar dratner avatar fiatjaf avatar heltonmarx avatar jeremyschlatter avatar jhvst avatar kshvakov avatar mbanzon avatar rasky avatar ready4god2513 avatar robbiet480 avatar sam-falvo avatar tamalsaha avatar tgallice avatar thrawn01 avatar tossp avatar yamada-wacul avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.