mailgunUser Guide


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


mailgun := Mailgun
  it.apiKey = "key-3ax6xnjp29jd6fds4gc373sgvjxteol0"
  it.domain = ""


See full send documentation.

  "from": "",
  "to": ",",
  "subject": "Hey There!",
  "text": "Hi :)"

Or use an Email instance:

email := Email
  from = ""
  to = [","]
  subject = "Hey There!"
  body = TextPart { text = "Hi :)" }


See full documentation.

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

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

Spam Complaints

See full documentation.

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


See full documentation.

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

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


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