const classmailgun::Mailgun

sys::Obj
  mailgun::Mailgun

Mailgun API

addBounce

Str:Obj addBounce(Str address, Int? errCode := null, Str? errMsg := null)

Adds a permanent bounce to bounce table. Updates existing recored if already there. Returns response from Mailgun if successful. Throws Err if fails for any reason.

See Mailgun documentation for bounces:

http://documentation.mailgun.net/api-bounces.html

addComplaint

Str:Obj addComplaint(Str address)

Adds an address to complaints table. Returns response from Mailgun if successful. Throws Err if fails for any reason.

See Mailgun documentation for complaints:

http://documentation.mailgun.net/api-complaints.html

addUnsubscribe

Str:Obj addUnsubscribe(Str address, Str tag := "*")

Add address to unsubscribe table. Returns response from Mailgun if successful. Throws Err if fails for any reason.

See Mailgun documentation for unsubscribes:

http://documentation.mailgun.net/api-unsubscribes.html

bounces

Str:Obj[] bounces(Int? limit := null, Int? skip := null)

Get list of bounces.

  • limit: Max number of records to return, or null for Mailgun default
  • skip: Number of records to skip, or null for Mailgun default

See Mailgun documentation for bounces:

http://documentation.mailgun.net/api-bounces.html

complaints

Str:Obj[] complaints(Int? limit := null, Int? skip := null)

Get list of spam complaints.

  • limit: Max number of records to return, or null for Mailgun default
  • skip: Number of records to skip, or null for Mailgun default

See Mailgun documentation for complaints:

http://documentation.mailgun.net/api-complaints.html

domain

const Str domain

Domain to use for your Mailgun account.

events

Str:Obj[] events([Str:Str]? filters := null, Obj? begin := null, Obj? end := null, Int? limit := null)

Get events for this Mailgun account.

  • filters: The set of filters to apply for retrieving events, or null for Mailgun default.
  • begin: a Date or DateTime to start the filter from, or null for Mailgun default.
  • end: a Date or DateTime to filter up to, or null for Mailgun default.
  • limit: Max number of items to return, or null for Mailgun default.

See Mailgun documentation for events:

https://documentation.mailgun.com/en/latest/api-events.html

from

const Str? from

Optional default address to use for From header if not specified in send or sendEmail.

getBounce

Str:Obj getBounce(Str address)

Get a single bounce event by email address. Returns response from Mailgun if successful. Throws Err if fails for any reason.

See Mailgun documentation for bounces:

http://documentation.mailgun.net/api-bounces.html

getComplaint

Str:Obj getComplaint(Str address)

Get a single spam complaint by email address. Returns response from Mailgun if successful. Throws Err if fails for any reason.

See Mailgun documentation for complaints:

http://documentation.mailgun.net/api-complaints.html

getUnsubscribe

Str:Obj[] getUnsubscribe(Str address)

Get a single unsubscribe record. Returns response from Mailgun if successful. Throws Err if fails for any reason.

See Mailgun documentation for unsubscribes:

http://documentation.mailgun.net/api-unsubscribes.html

invoke

Obj invoke(Str method, Uri endpoint, [Str:Obj]? params := null)

Invoke a REST API with given arguments. If method is "GET" params sent in query string, otherse as request body.

invoke("GET", `/log`, ["limit":"25"])

API calls that return a list of items will include paging information in the first and last item. You can pass those items to the various paging methods to retrieve more items.

isValidAddress

Bool isValidAddress(Str address)

Convenience to determine if an email address is valid or not

log

@Deprecated { msg="Use the events api instead" }
Str:Obj[] log(Int? limit := null, Int? skip := null)

Get log entries for this Mailgun account.

  • limit: Max number of records to return, or null for Mailgun default
  • skip: Number of records to skip, or null for Mailgun default

See Mailgun documentation for log:

http://documentation.mailgun.net/api-logs.html

make

new make(|This? f := null)

Constructor.

pageFirst

Str:Obj[] pageFirst(Str:Obj item)

Get the first page items. See invoke for details.

pageLast

Str:Obj[] pageLast(Str:Obj item)

Get the last page items. See invoke for details.

pageNext

Str:Obj[] pageNext(Str:Obj item)

Get the next page of items. See invoke for details.

pagePrev

Str:Obj[] pagePrev(Str:Obj item)

Get the previous page of items. See invoke for details.

privApiKey

const Str privApiKey

Private API key for your Mailgun account.

pubApiKey

const Str? pubApiKey

Public API key for your Mailgun account.

removeBounce

Str:Obj removeBounce(Str addressOrId)

Remove a bounce event. Returns response from Mailgun if successful. Throws Err if fails for any reason.

See Mailgun documentation for bounces:

http://documentation.mailgun.net/api-bounces.html

removeComplaint

Str:Obj removeComplaint(Str addressOrId)

Remove a given spam complaint. Returns response from Mailgun if successful. Throws Err if fails for any reason.

See Mailgun documentation for complaints:

http://documentation.mailgun.net/api-complaints.html

removeTag

Str:Obj removeTag(Str tag)

Deletes all counters for given tag. Returns response from Mailgun. Throws Err if fails for any reason.

See Mailgun documentation for stats:

http://documentation.mailgun.net/api-bounces.html

removeUnsubscribe

Str:Obj removeUnsubscribe(Str addressOrId)

Remove an address from unsubscribe table. Returns response from Mailgun if successful. Throws Err if fails for any reason.

See Mailgun documentation for unsubscribes:

http://documentation.mailgun.net/api-unsubscribes.html

send

Str:Obj send(Str:Obj params)

Send message using given params. See Mailgun documentation for available parameters:

http://documentation.mailgun.net/api-sending.html

send([
  "from":    "Test <me@example.com>",
  "to":      "foo@example.com, bar@example.com",
  "subject": "Test Message!",
  "text":    "Hey there!",
])

Returns response from Mailgun if successful. Throws Err if fails for any reason.

sendEmail

Str:Obj sendEmail(Email email)

Convenience to use an Email instance for send.

stats

Str:Obj[] stats(Str event, Date? start := null, Int? limit := null, Int? skip := null)

Get list of event stat items. Each record counts for one event per one day. Throws Err if fails for any reason.

Available event names:

  • sent
  • delivered
  • bounced
  • dropped
  • complained
  • unsubscribed
  • opened
  • clicked

See Mailgun documentation for stats:

http://documentation.mailgun.net/api-bounces.html

unsubscribes

Str:Obj[] unsubscribes(Int? limit := null, Int? skip := null)

Get list of unsubscribes.

  • limit: Max number of records to return, or null for Mailgun default
  • skip: Number of records to skip, or null for Mailgun default

See Mailgun documentation for unsubscribes:

http://documentation.mailgun.net/api-unsubscribes.html

validateAddress

Str:Obj? validateAddress(Str address)

Validate the email address using Mailgun's email validation service