mailgunUser Guide

Overview

Mailgun is a simple Fantom API wrapper for the Mailgun email service.

Usage

mailgun := Mailgun
{
  it.apiKey = "key-3ax6xnjp29jd6fds4gc373sgvjxteol0"
  it.domain = "samples.mailgun.org"
}

Sending

See full send documentation.

mailgun.send([
  "from": "me@samples.mailgun.org",
  "to": "alex@mailgun.net, ev@mailgun.net",
  "subject": "Hey There!",
  "text": "Hi :)"
])

Or use an Email instance:

email := Email
{
  from = "me@samples.mailgun.org"
  to = ["alex@mailgun.net, ev@mailgun.net"]
  subject = "Hey There!"
  body = TextPart { text = "Hi :)" }
}
mailgun.sendEmail(email)

Unsubscribes

See full documentation.

mailgun.unsubscribe                            // get unsubscribe table
mailgun.addUnsubscribe("alex@mailgun.net")     // add address to unsub table
mailgun.getUnsubscribe("alex@mailgun.net")     // get all unsub entries for address
mailgun.removeUnsubscribe("alex@mailgun.net")  // remove all unsub entries for address

// add with tags
mailgun.addUnsubscribe("alex@mailgun.net", "someTag")

Spam Complaints

See full documentation.

mailgun.complaints                           // get complaints table
mailgun.addComplaint("alex@mailgun.net")     // add address to complaints table
mailgun.getComplaint("alex@mailgun.net")     // get complaints entry for address
mailgun.removeComplaint("alex@mailgun.net")  // remove address from complaints table

Bounces

See full documentation.

mailgun.bounces                           // get bounces table
mailgun.addBounce("alex@mailgun.net")     // add address to bounce table
mailgun.getBounce("alex@mailgun.net")     // get bounce entry for address
mailgun.removeBounce("alex@mailgun.net")  // remove address from bounce table

// add with specific error code and message
mailgun.addBounce("alex@mailgun.net", 551, "The recipient is not local to the server.")

Logs

See full log documentation.

logs := mailgun.log

Everything Else

Not every API has first-class support yet. And just in case Mailgun adds new APIs that are't yet implemented here, you can drop down and use the invoke method to directly access Mailgun's REST API:

// both lines are equivalent
mailgun.log(25)
mailgun.invoke("GET", `/log`, ["limit":"25"])

The return type for invoke will either be a Str:Obj or it will be a [Str:Obj][] list. Refert to the Mailgun documentation on expected result.