mailgun package - github.com/mailgun/mailgun-go/v5 - Go Packages (original) (raw)

Package mailgun provides methods for interacting with the Mailgun API. It automates the HTTP request/response cycle, encodings, and other details needed by the API. This SDK lets you do everything the API lets you, in a more Go-friendly way.

For further information please see the Mailgun documentation athttp://documentation.mailgun.com/

Original Author: Michael Banzon Contributions: Samuel A. Falvo II <sam.falvo %at% rackspace.com> Derrick J. Wippler <thrawn01 %at% gmail.com>

Examples

All functions and method have a corresponding test, so if you don't find an example for a function you'd like to know more about, please check for a corresponding test. Of course, contributions to the documentation are always welcome as well. Feel free to submit a pull request or open a Github issue if you cannot find an example to suit your needs.

List iterators

Most methods that begin with `List` return an iterator which simplfies paging through large result sets returned by the mailgun API. Most `List` methods allow you to specify a `Limit` parameter which as you'd expect, limits the number of items returned per page. Note that, at present, Mailgun imposes its own cap of 100 items per page, for all API endpoints.

For example, the following iterates over all pages of events 100 items at a time

mg := mailgun.NewMailgun("your-api-key") it := mg.ListEvents(&mailgun.ListEventOptions{Limit: 100})

// The entire operation should not take longer than 30 seconds ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) defer cancel()

// For each page of 100 events var page []mailgun.Event for it.Next(ctx, &page) { for _, e := range page { // Do something with 'e' } }

License

Copyright (c) 2013-2019, Michael Banzon. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the names of Mailgun, Michael Banzon, nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View Source

const (

APIBase   = "https://api.mailgun.net"
APIBaseUS = [APIBase](#APIBase)
APIBaseEU = "https://api.eu.mailgun.net"

)

MaxNumberOfRecipients represents the largest batch of recipients that Mailgun can support in a single API call. This figure includes To:, Cc:, Bcc:, etc. recipients.

MaxNumberOfTags represents the maximum number of tags that can be added for a message

The UserAgent identifies the client to the server, for logging purposes. In the event of problems requiring a human administrator's assistance, this user agent allows them to identify the client from human-generated activity.

Version of current release TODO(vtopc): automate this

Debug set true to write the HTTP requests in curl for to stdout

ErrEmptyParam is returned when a required parameter is missing.

ErrInvalidMessage is returned by `Send()` when the `mailgun.CommonMessage` struct is incomplete

GetStatusFromErr extracts the http status code from error object

TimeToFloat given time.Time{} return a float64 as given in mailgun event timestamps

Err if an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

type BufferAttachment struct { Filename string Buffer []byte }

Client bundles data needed by a large number of methods in order to interact with the Mailgun API.

NewMailgun creates a new client instance.

func NewMailgunFromEnv() (*Client, error)

NewMailgunFromEnv returns a new Mailgun client using the environment variables MG_API_KEY, MG_URL, and MG_WEBHOOK_SIGNING_KEY

APIBase returns the API Base URL configured for this client.

APIKey returns the API key configured for this client.

AddBounce files a bounce report. Address identifies the intended recipient of the message that bounced. Code corresponds to the numeric response given by the e-mail server which rejected the message. Error provides the corresponding human-readable reason for the problem. For example, here's how the these two fields relate. Suppose the SMTP server responds with an error, as below. Then, ...

550 Requested action not taken: mailbox unavailable __/______________________________________________/ | | -- Code -- Error

Note that both code and error exist as strings, even though code will report as a number.

AddBounces adds a list of bounces to the bounce list

func (*Client) AddDomainIP

AddDomainIP assign a dedicated IP to the domain specified.

func (*Client) AddDomainToMonitoring added in v5.4.0

AddDomainToMonitoring adds a single domain to an account

func (mg *Client) AddOverrideHeader(k, v string)

AddOverrideHeader allows the user to specify additional headers that will be included in the HTTP request This is mostly useful for testing the Mailgun API hosted at a different endpoint.

AddTemplateVersion adds a template version to a template

ChangeCredentialPassword attempts to alter the indicated credential's password.

CreateComplaint registers the specified address as a recipient who has complained of receiving spam from your domain.

CreateCredential attempts to create associate a new principle with your domain.

func (*Client) CreateDomain

CreateDomain instructs Mailgun to create a new domain for your account. The name parameter identifies the domain. The smtpPassword parameter provides an access credential for the domain. The spamAction domain must be one of Delete, Tag, or Disabled. The wildcard parameter instructs Mailgun to treat all subdomains of this domain uniformly if true, and as different domains if false.

CreateExport creates an export based on the URL given

CreateMailingList creates a new mailing list under your Mailgun account. You need specify only the Address and Name members of the prototype; Description, AccessLevel and ReplyPreference are optional. If unspecified, the Description remains blank, while AccessLevel defaults to Everyone and ReplyPreference defaults to List.

CreateMember registers a new member of the indicated mailing list. If merge is set to true, then the registration may update an existing Member's settings. Otherwise, an error will occur if you attempt to add a member with a duplicate e-mail address.

CreateMemberList registers multiple Members and non-Member members to a single mailing list in a single round-trip. u indicates if the existing members should be updated or duplicates should be updated. Use All to elect not to provide a default. The newMembers list can take one of two JSON-encodable forms: a slice of strings, or a slice of Member structures. If a simple slice of strings is passed, each string refers to the member's e-mail address. Otherwise, each Member needs to have at least the Address field filled out. Other fields are optional, but may be set according to your needs.

CreateRoute installs a new route for your domain. The route structure you provide serves as a template, and only a subset of the fields influence the operation. See the Route structure definition for more details.

CreateSubaccount instructs Mailgun to create a new account (Subaccount) that is linked to the primary account. Subaccounts are child accounts that share the same plan and usage allocations as the primary, but have their own assets (sending domains, unique users, API key, SMTP credentials, settings, statistics and site login). All you need is the name of the subaccount.

Create a new template which can be used to attach template versions to

CreateUnsubscribe adds an e-mail address to the domain's unsubscription table.

CreateUnsubscribes adds multiple e-mail addresses to the domain's unsubscription table. TODO(vtopc): Doc says it's domain ID, not name. Rename arg to clarify.

https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/unsubscribe

CreateWebhook installs a new webhook for your domain.

DeleteBounce removes all bounces associated with the provided e-mail address.

DeleteBounceList removes all bounces in the bounce list

DeleteComplaint removes a previously registered e-mail address from the list of people who complained of receiving spam from your domain.

DeleteCredential attempts to remove the indicated principle from the domain.

func (*Client) DeleteDomain

DeleteDomain instructs Mailgun to dispose of the named domain name

func (*Client) DeleteDomainIP

DeleteDomainIP unassign an IP from the domain specified.

DeleteMailingList removes all current members of the list, then removes the list itself. Attempts to send e-mail to the list will fail subsequent to this call.

DeleteMember removes the member from the list.

func (*Client) DeleteMonitoredDomain added in v5.4.0

DeleteMonitoredDomain deletes a single domain from an account

DeleteRoute removes the specified route from your domain's configuration. To avoid ambiguity, Mailgun identifies the route by unique ID. See the Route structure definition and the Mailgun API documentation for more details.

DeleteTag removes all counters for a particular tag, including the tag itself.

Delete a template given a template name

Delete a specific version of a template

DeleteUnsubscribe removes the e-mail address given from the domain's unsubscription table. If passing in an ID (discoverable from, e.g., ListUnsubscribes()), the e-mail address associated with the given ID will be removed.

DeleteUnsubscribeWithTag removes the e-mail address given from the domain's unsubscription table with a matching tag. If passing in an ID (discoverable from, e.g., ListUnsubscribes()), the e-mail address associated with the given ID will be removed.

DeleteWebhook removes the specified webhook from your domain's configuration.

DisableSubaccount instructs Mailgun to disable subaccount.

EnableSubaccount instructs Mailgun to enable subaccount.

GetBounce retrieves a single bounce record, if any exist, for the given recipient address.

GetComplaint returns a single complaint record filed by a recipient at the email address provided. If no complaint exists, the Complaint instance returned will be empty.

func (*Client) GetDomain

GetDomain retrieves detailed information about the named domain.

func (*Client) GetDomainConnection

GetDomainConnection returns delivery connection settings for the defined domain Deprecated: use GetDomain instead TODO(v6): remove

func (*Client) GetDomainTracking

GetDomainTracking returns tracking settings for a domain

GetExport gets an export by id

Download an export by ID. This will respond with a '302 Moved' with the Location header of temporary S3 URL if it is available.

GetIP returns information about the specified IP

GetIPWarmup retrieves the details of a warmup in progress for the specified IP address

GetMailingList allows your application to recover the complete List structure representing a mailing list, so long as you have its e-mail address. TODO(v6): rename to GetMailingListByAddress to be more explicit.

GetMember returns a complete Member structure for a member of a mailing list, given only their subscription e-mail address.

GetRoute retrieves the complete route definition associated with the unique route ID.

GetStoredAttachment retrieves the raw MIME body of a received e-mail message attachment.

GetStoredMessage retrieves information about a received e-mail message. This provides visibility into, e.g., replies to a message sent to a mailing list.

GetStoredMessageRaw retrieves the raw MIME body of a received e-mail message. Compared to GetStoredMessage, it gives access to the unparsed MIME body, and thus delegates to the caller the required parsing.

GetSubaccount retrieves detailed information about subaccount using subaccountID.

GetTag retrieves metadata about the tag from the api

GetTagLimits returns tracking settings for a domain

GetTemplate gets a template given the template name

GetTemplateVersion gets a specific version of a template

GetUnsubscribe retrieves a single unsubscribe record. Can be used to check if a given address is present in the list of unsubscribed users.

GetWebhook retrieves the currently assigned webhook URL associated with the provided type of webhook.

HTTPClient returns the HTTP client configured for this client.

ListAlerts returns a list of all configured alert settings for your account.

ListAlertsEvents list of events that you can choose to receive alerts for.

func (mg *Client) ListBounces(domain string, opts *ListOptions) *BouncesIterator

ListBounces returns a complete set of bounces logged against the sender's domain, if any. The results include the total number of bounces (regardless of skip or limit settings), and the slice of bounces specified, if successful. Note that the length of the slice may be smaller than the total number of bounces.

func (mg *Client) ListComplaints(domain string, opts *ListOptions) *ComplaintsIterator

ListComplaints returns a set of spam complaints registered against your domain. Recipients of your messages can click on a link which sends feedback to Mailgun indicating that the message they received is, to them, spam.

func (mg *Client) ListCredentials(domain string, opts *ListOptions) *CredentialsIterator

ListCredentials returns the (possibly zero-length) list of credentials associated with your domain.

func (*Client) ListDomainIPs

ListDomainIPs returns a list of IPs currently assigned to the specified domain.

func (*Client) ListDomains

func (mg *Client) ListDomains(opts *ListDomainsOptions) *DomainsIterator

ListDomains retrieves a set of domains from Mailgun.

ListEvents creates a new iterator to fetch a page of events from the events api

ListExports lists all exports created within the past 24 hours

func (*Client) ListIPDomains added in v5.2.0

ListIPDomains retrieves a list of domains for the specified IP address.

func (mg *Client) ListIPWarmups() *IPWarmupsIterator

ListIPWarmups retrieves a list of warmups in progress in the account

ListIPs returns a list of IPs assigned to your account, including their warmup and assignable to pools status if applicable.

func (mg *Client) ListMailingLists(opts *ListOptions) *ListsIterator

ListMailingLists returns the specified set of mailing lists administered by your account.

func (mg *Client) ListMembers(listAddress string, opts *ListOptions) *MemberListIterator

func (mg *Client) ListRoutes(opts *ListOptions) *RoutesIterator

ListRoutes allows you to iterate through a list of routes returned by the API

func (mg *Client) ListSubaccounts(opts *ListSubaccountsOptions) *SubaccountsIterator

ListSubaccounts retrieves a set of subaccount linked to the primary Mailgun account.

ListTags returns a cursor used to iterate through a list of tags

it := mg.ListTags(nil) var page []mailgun.Tag for it.Next(&page) { for _, tag := range(page) { // Do stuff with tags } } if it.Err() != nil { log.Fatal(it.Err()) }

func (mg *Client) ListTemplateVersions(domain, templateName string, opts *ListOptions) *TemplateVersionsIterator

ListTemplateVersions lists all the versions of a specific template

List all available templates

func (mg *Client) ListUnsubscribes(domain string, opts *ListOptions) *UnsubscribesIterator

ListUnsubscribes fetches the list of unsubscribes

ListWebhooks returns the complete set of webhooks configured for your domain. Note that a zero-length mapping is not an error.

func (mg *Client) PollEvents(domain string, opts *ListEventOptions) *EventPoller

PollEvents polls the events api and return new events as they occur

it = mg.PollEvents("example.com", &ListEventOptions{ // Only events with a timestamp after this date/time will be returned Begin: time.Now().Add(time.Second * -3), // How often we poll the api for new events PollInterval: time.Second * 4 })

var events []Event ctx, cancel := context.WithCancel(context.Background())

// Blocks until new events appear or context is cancelled for it.Poll(ctx, &events) { for _, event := range(events) { fmt.Printf("Event %+v\n", event) } } if it.Err() != nil { log.Fatal(it.Err()) }

ReSend given a storage url resend the stored message to the specified recipients

func (mg *Client) RemoveOnBehalfOfSubaccount()

RemoveOnBehalfOfSubaccount remove X-Mailgun-On-Behalf-Of header for primary usage.

Send attempts to queue a message (see PlainMessage, MimeMessage and its methods) for delivery. It returns the Mailgun server response, which consists of two components:

The status and message ID are only returned if no error occurred.

Returned error can be wrapped internal and standard Go errors like `url.Error`. The error can also be of type mailgun.UnexpectedResponseError which contains the error returned by the mailgun API.

See the public mailgun documentation for all possible return codes and error messages

SetAPIBase updates the API Base URL for this client.

// For EU Customers mg.SetAPIBase(mailgun.APIBaseEU)

// For US Customers mg.SetAPIBase(mailgun.APIBaseUS)

// Set a custom base API mg.SetAPIBase("https://localhost")

SetHTTPClient updates the HTTP client for this client.

func (mg *Client) SetOnBehalfOfSubaccount(subaccountId string)

SetOnBehalfOfSubaccount sets X-Mailgun-On-Behalf-Of header to SUBACCOUNT_ACCOUNT_ID in order to perform API request on behalf of subaccount.

func (mg *Client) SetWebhookSigningKey(webhookSigningKey string)

SetWebhookSigningKey updates the webhook signing key for this client

func (*Client) UpdateDomain

UpdateDomain updates a domain's attributes.

func (*Client) UpdateDomainConnection

UpdateDomainConnection updates the specified delivery connection settings for the defined domain Deprecated: use UpdateDomain instead TODO(v6): remove

UpdateMailingList allows you to change various attributes of a list. Address, Name, Description, AccessLevel and ReplyPreference are all optional; only those fields which are set in the prototype will change.

Be careful! If changing the address of a mailing list, e-mail sent to the old address will not succeed. Make sure you account for the change accordingly.

UpdateMember lets you change certain details about the indicated mailing list member. Address, Name, Vars, and Subscribed fields may be changed.

UpdateRoute provides an "in-place" update of the specified route. Only those route fields which are non-zero or non-empty are updated. All other fields remain as-is.

Update the name and description of a template

Update the comment and mark a version of a template active

UpdateWebhook replaces one webhook setting for another.

func (*Client) VerifyAndReturnDomain

VerifyAndReturnDomain verifies the domains DNS records (includes A, CNAME, SPF, DKIM and MX records) to ensure the domain is ready and able to send. Deprecated: use VerifyDomain instead. TODO(v6): remove this method

func (*Client) VerifyDomain added in v5.4.0

VerifyDomain verifies the domains DNS records (includes A, CNAME, SPF, DKIM and MX records) to ensure the domain is ready and able to send.

VerifyWebhookSignature - use this method to parse the webhook signature given as JSON in the webhook response

func (mg *Client) WebhookSigningKey() string

WebhookSigningKey returns the webhook signing key configured for this client

type CommonMessage struct {

}

CommonMessage contains both the message text and the envelope for an e-mail message. TODO(vtopc): create AddOption(key string, value string) for `o:` options?

func (m *CommonMessage) AddAttachment(attachment string)

AddAttachment arranges to send a file from the filesystem along with the e-mail message. The attachment parameter is a filename, which must refer to a file which actually resides in the local filesystem.

func (m *CommonMessage) AddBufferAttachment(filename string, buffer []byte)

AddBufferAttachment arranges to send a file along with the e-mail message. File contents are read from the []byte array provided The filename parameter is the resulting filename of the attachment. The buffer parameter is the []byte array which contains the actual bytes to be used as the contents of the attached file.

func (*CommonMessage) AddDomain

AddDomain allows you to use a separate domain for the type of messages you are sending.

func (m *CommonMessage) AddHeader(header, value string)

AddHeader allows you to send custom MIME headers with the message.

AddInline arranges to send a file along with the e-mail message, but does so in a way that its data remains "inline" with the rest of the message. This can be used to send image or font data along with an HTML-encoded message body. The attachment parameter is a filename, which must refer to a file which actually resides in the local filesystem.

AddReaderAttachment arranges to send a file along with the e-mail message. File contents are read from an io.ReadCloser. The filename parameter is the resulting filename of the attachment. The readCloser parameter is the io.ReadCloser that reads the actual bytes to be used as the contents of the attached file.

AddReaderInline arranges to send a file along with the e-mail message. File contents are read from an io.ReadCloser. The filename parameter is the resulting filename of the attachment. The readCloser parameter is the io.ReadCloser that reads the actual bytes to be used as the contents of the attached file.

AddTag attaches tags to the message. Tags are useful for metrics gathering and event tracking purposes. Refer to the Mailgun documentation for further details.

AddTemplateVariable adds a template variable to the map of template variables, replacing the variable if it is already there. This is used for server-side message templates and can nest arbitrary values. At send time, the resulting map will be converted into a JSON string and sent as a header in the X-Mailgun-Variables header.

AddVariable lets you associate a set of variables with messages you send, which Mailgun can use to, in essence, complete form-mail. Refer to the Mailgun documentation for more information.

func (m *CommonMessage) BufferAttachments() []BufferAttachment

func (m *CommonMessage) EnableNativeSend()

EnableNativeSend allows the return path to match the address in the CommonMessage.Headers.From: field when sending from Mailgun rather than the usual bounce+ address in the return path.

func (m *CommonMessage) EnableTestMode()

EnableTestMode allows submittal of a message, such that it will be discarded by Mailgun. This facilitates testing client-side software without actually consuming e-mail resources.

Headers retrieve the http headers associated with this message

func (m *CommonMessage) NativeSend() bool

func (m *CommonMessage) ReaderAttachments() []ReaderAttachment

func (m *CommonMessage) ReaderInlines() []ReaderAttachment

func (m *CommonMessage) RequireTLS() bool

func (m *CommonMessage) SetDKIM(dkim bool)

SetDKIM arranges to send the o:dkim header with the message, and sets its value accordingly. Refer to the Mailgun documentation for more information.

SetDeliveryTime schedules the message for transmission at the indicated time. Pass nil to remove any installed schedule. Refer to the Mailgun documentation for more information.

func (m *CommonMessage) SetReplyTo(recipient string)

SetReplyTo sets the receiver who should receive replies

func (m *CommonMessage) SetRequireTLS(b bool)

SetRequireTLS information is found in the Mailgun documentation.

SetSTOPeriod toggles Send Time Optimization (STO) on a per-message basis. String should be set to the number of hours in [0-9]+h format, with the minimum being 24h and the maximum being 72h. Refer to the Mailgun documentation for more information.

func (m *CommonMessage) SetSkipVerification(b bool)

SetSkipVerification information is found in the Mailgun documentation.

func (m *CommonMessage) SetTemplateRenderText(render bool)

SetTemplateRenderText information is found in the Mailgun documentation.

func (m *CommonMessage) SetTemplateVersion(tag string)

SetTemplateVersion information is found in the Mailgun documentation.

func (m *CommonMessage) SetTracking(tracking bool)

SetTracking sets the o:tracking message parameter to adjust, on a message-by-message basis, whether or not Mailgun will rewrite URLs to facilitate event tracking. Events tracked includes opens, clicks, unsubscribes, etc. Note: simply calling this method ensures that the o:tracking header is passed in with the message. Its yes/no setting is determined by the call's parameter. Note that this header is not passed on to the final recipient(s). Refer to the Mailgun documentation for more information.

func (m *CommonMessage) SetTrackingClicks(trackingClicks bool)

SetTrackingClicks information is found in the Mailgun documentation.

func (m *CommonMessage) SetTrackingOpens(trackingOpens bool)

SetTrackingOpens information is found in the Mailgun documentation.

func (m *CommonMessage) SetTrackingOptions(options *TrackingOptions)

SetTrackingOptions sets o:tracking, o:tracking-clicks, o:tracking-pixel-location-top, and o:tracking-opens at once.

func (m *CommonMessage) SkipVerification() bool

func (m *CommonMessage) TemplateRenderText() bool

func (m *CommonMessage) TemplateVersionTag() string

func (m *CommonMessage) Tracking() *bool

func (m *CommonMessage) TrackingOpens() *bool

func (m *CommonMessage) TrackingPixelLocationTop() *string

If an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

If an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Offset returns the current offset of the iterator

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

type DomainsIterator

func (*DomainsIterator) Err

Err if an error occurred during iteration `Err()` will return non nil

func (*DomainsIterator) First

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

func (*DomainsIterator) Last

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

func (*DomainsIterator) Next

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

func (*DomainsIterator) Offset

func (ri *DomainsIterator) Offset() int

Offset returns the current offset of the iterator

func (*DomainsIterator) Previous

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

EventIterator maintains the state necessary for paging though small parcels of a larger set of events.

If an error occurred during iteration `Err()` will return non nil

First retrieves the first page of events from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of events from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of events from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Previous retrieves the previous page of events from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

type EventPoller struct {

}

EventPoller maintains the state necessary for polling events

If an error occurred during polling `Err()` will return non nil

type FormDataPayload struct { Values []keyValuePair Files []keyValuePair ReadClosers []keyNameRC Buffers []keyNameBuff

}

func NewFormDataPayload() *FormDataPayload

ForwardedMessage represents the payload the server will get on match You can use ExtractForwardRoute() to extract PostForm into the struct, or you can use only the struct and parse the form manually

ExtractForwardedMessage extracts the forward route payload values from a parsed PostForm Example usage:

func Handler(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { log.Fatal(err) } forwardRoute := mailgun.ExtractForwardedMessage(r.PostForm) fmt.Printf("Forwarded message: %#v", forwardRoute) }

type IPDomainsIterator added in v5.2.0

func (*IPDomainsIterator) Err added in v5.2.0

Err if an error occurred during iteration `Err()` will return non nil

func (*IPDomainsIterator) First added in v5.2.0

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

func (*IPDomainsIterator) Last added in v5.2.0

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

func (*IPDomainsIterator) Next added in v5.2.0

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

func (*IPDomainsIterator) Offset added in v5.2.0

func (ri *IPDomainsIterator) Offset() int

Offset returns the current offset of the iterator

func (*IPDomainsIterator) Previous added in v5.2.0

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

Err if an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

type ListAPIKeysOptions struct { DomainName string Kind string }

type ListAlertsEventsOptions struct{}

type ListAlertsOptions struct{}

ListEventOptions modifies the behavior of ListEvents()

type ListOptions struct { Limit int }

ListOptions used by List methods to specify what list parameters to send to the mailgun API

type ListSubaccountsOptions struct { Limit int Skip int SortArray string Enabled bool }

type ListTagOptions struct {

Limit [int](/builtin#int)

Prefix [string](/builtin#string)

}

type ListTemplateOptions struct { Limit int Active bool }

Err if an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

type Mailgun interface { APIBase() string APIKey() string HTTPClient() *http.Client SetHTTPClient(client *http.Client) SetAPIBase(url string) error

Send(ctx [context](/context).[Context](/context#Context), m [Message](#Message)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[SendMessageResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#SendMessageResponse), [error](/builtin#error))
ReSend(ctx [context](/context).[Context](/context#Context), url [string](/builtin#string), recipients ...[string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[SendMessageResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#SendMessageResponse), [error](/builtin#error))

ListBounces(domain [string](/builtin#string), opts *[ListOptions](#ListOptions)) *[BouncesIterator](#BouncesIterator)
GetBounce(ctx [context](/context).[Context](/context#Context), domain, address [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Bounce](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Bounce), [error](/builtin#error))
AddBounce(ctx [context](/context).[Context](/context#Context), domain, address, code, err [string](/builtin#string)) [error](/builtin#error)
DeleteBounce(ctx [context](/context).[Context](/context#Context), domain, address [string](/builtin#string)) [error](/builtin#error)
DeleteBounceList(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string)) [error](/builtin#error)

ListMetrics(opts [MetricsOptions](#MetricsOptions)) (*[MetricsIterator](#MetricsIterator), [error](/builtin#error))

GetTag(ctx [context](/context).[Context](/context#Context), domain, tag [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Tag](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Tag), [error](/builtin#error))
DeleteTag(ctx [context](/context).[Context](/context#Context), domain, tag [string](/builtin#string)) [error](/builtin#error)
ListTags(domain [string](/builtin#string), opts *[ListTagOptions](#ListTagOptions)) *[TagIterator](#TagIterator)

ListDomains(opts *[ListDomainsOptions](#ListDomainsOptions)) *[DomainsIterator](#DomainsIterator)
GetDomain(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string), opts *[GetDomainOptions](#GetDomainOptions)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[GetDomainResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#GetDomainResponse), [error](/builtin#error))
CreateDomain(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string), opts *[CreateDomainOptions](#CreateDomainOptions)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[GetDomainResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#GetDomainResponse), [error](/builtin#error))
VerifyDomain(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[GetDomainResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#GetDomainResponse), [error](/builtin#error))
UpdateDomain(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string), opts *[UpdateDomainOptions](#UpdateDomainOptions)) [error](/builtin#error)
DeleteDomain(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string)) [error](/builtin#error)

VerifyAndReturnDomain(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[GetDomainResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#GetDomainResponse), [error](/builtin#error))
ListIPDomains(ip [string](/builtin#string), opts *[ListIPDomainOptions](#ListIPDomainOptions)) *[IPDomainsIterator](#IPDomainsIterator)


UpdateDomainConnection(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string), dc [mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[DomainConnection](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#DomainConnection)) [error](/builtin#error)

GetDomainConnection(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[DomainConnection](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#DomainConnection), [error](/builtin#error))

GetDomainTracking(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[DomainTracking](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#DomainTracking), [error](/builtin#error))
UpdateClickTracking(ctx [context](/context).[Context](/context#Context), domain, active [string](/builtin#string)) [error](/builtin#error)
UpdateUnsubscribeTracking(ctx [context](/context).[Context](/context#Context), domain, active, htmlFooter, textFooter [string](/builtin#string)) [error](/builtin#error)
UpdateOpenTracking(ctx [context](/context).[Context](/context#Context), domain, active [string](/builtin#string)) [error](/builtin#error)

UpdateDomainDkimSelector(ctx [context](/context).[Context](/context#Context), domain, dkimSelector [string](/builtin#string)) [error](/builtin#error)

GetStoredMessage(ctx [context](/context).[Context](/context#Context), url [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[StoredMessage](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#StoredMessage), [error](/builtin#error))
GetStoredMessageRaw(ctx [context](/context).[Context](/context#Context), id [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[StoredMessageRaw](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#StoredMessageRaw), [error](/builtin#error))
GetStoredAttachment(ctx [context](/context).[Context](/context#Context), url [string](/builtin#string)) ([][byte](/builtin#byte), [error](/builtin#error))

ListCredentials(domain [string](/builtin#string), opts *[ListOptions](#ListOptions)) *[CredentialsIterator](#CredentialsIterator)
CreateCredential(ctx [context](/context).[Context](/context#Context), domain, login, password [string](/builtin#string)) [error](/builtin#error)
ChangeCredentialPassword(ctx [context](/context).[Context](/context#Context), domain, login, password [string](/builtin#string)) [error](/builtin#error)
DeleteCredential(ctx [context](/context).[Context](/context#Context), domain, login [string](/builtin#string)) [error](/builtin#error)

ListUnsubscribes(domain [string](/builtin#string), opts *[ListOptions](#ListOptions)) *[UnsubscribesIterator](#UnsubscribesIterator)
GetUnsubscribe(ctx [context](/context).[Context](/context#Context), domain, address [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Unsubscribe](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Unsubscribe), [error](/builtin#error))
CreateUnsubscribe(ctx [context](/context).[Context](/context#Context), domain, address, tag [string](/builtin#string)) [error](/builtin#error)
CreateUnsubscribes(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string), unsubscribes [][mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Unsubscribe](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Unsubscribe)) [error](/builtin#error)
DeleteUnsubscribe(ctx [context](/context).[Context](/context#Context), domain, address [string](/builtin#string)) [error](/builtin#error)
DeleteUnsubscribeWithTag(ctx [context](/context).[Context](/context#Context), domain, address, tag [string](/builtin#string)) [error](/builtin#error)

ListComplaints(domain [string](/builtin#string), opts *[ListOptions](#ListOptions)) *[ComplaintsIterator](#ComplaintsIterator)
GetComplaint(ctx [context](/context).[Context](/context#Context), domain, address [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Complaint](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Complaint), [error](/builtin#error))
CreateComplaint(ctx [context](/context).[Context](/context#Context), domain, address [string](/builtin#string)) [error](/builtin#error)
CreateComplaints(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string), addresses [][string](/builtin#string)) [error](/builtin#error)
DeleteComplaint(ctx [context](/context).[Context](/context#Context), domain, address [string](/builtin#string)) [error](/builtin#error)

ListRoutes(opts *[ListOptions](#ListOptions)) *[RoutesIterator](#RoutesIterator)
GetRoute(ctx [context](/context).[Context](/context#Context), id [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Route](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Route), [error](/builtin#error))
CreateRoute(ctx [context](/context).[Context](/context#Context), route [mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Route](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Route)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Route](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Route), [error](/builtin#error))
DeleteRoute(ctx [context](/context).[Context](/context#Context), id [string](/builtin#string)) [error](/builtin#error)
UpdateRoute(ctx [context](/context).[Context](/context#Context), id [string](/builtin#string), r [mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Route](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Route)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Route](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Route), [error](/builtin#error))

ListWebhooks(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string)) (map[[string](/builtin#string)][][string](/builtin#string), [error](/builtin#error))
CreateWebhook(ctx [context](/context).[Context](/context#Context), domain, kind [string](/builtin#string), url [][string](/builtin#string)) [error](/builtin#error)
DeleteWebhook(ctx [context](/context).[Context](/context#Context), domain, kind [string](/builtin#string)) [error](/builtin#error)
GetWebhook(ctx [context](/context).[Context](/context#Context), domain, kind [string](/builtin#string)) ([][string](/builtin#string), [error](/builtin#error))
UpdateWebhook(ctx [context](/context).[Context](/context#Context), domain, kind [string](/builtin#string), url [][string](/builtin#string)) [error](/builtin#error)
VerifyWebhookSignature(sig [mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Signature](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Signature)) (verified [bool](/builtin#bool), err [error](/builtin#error))

ListMailingLists(opts *[ListOptions](#ListOptions)) *[ListsIterator](#ListsIterator)
CreateMailingList(ctx [context](/context).[Context](/context#Context), ml [mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[MailingList](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#MailingList)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[MailingList](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#MailingList), [error](/builtin#error))
DeleteMailingList(ctx [context](/context).[Context](/context#Context), address [string](/builtin#string)) [error](/builtin#error)
GetMailingList(ctx [context](/context).[Context](/context#Context), address [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[MailingList](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#MailingList), [error](/builtin#error))
UpdateMailingList(ctx [context](/context).[Context](/context#Context), address [string](/builtin#string), ml [mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[MailingList](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#MailingList)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[MailingList](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#MailingList), [error](/builtin#error))

ListMembers(listAddress [string](/builtin#string), opts *[ListOptions](#ListOptions)) *[MemberListIterator](#MemberListIterator)
GetMember(ctx [context](/context).[Context](/context#Context), memberAddress, listAddress [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Member](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Member), [error](/builtin#error))
CreateMember(ctx [context](/context).[Context](/context#Context), merge [bool](/builtin#bool), listAddress [string](/builtin#string), member [mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Member](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Member)) [error](/builtin#error)
CreateMemberList(ctx [context](/context).[Context](/context#Context), subscribed *[bool](/builtin#bool), listAddress [string](/builtin#string), newMembers [][any](/builtin#any)) [error](/builtin#error)
UpdateMember(ctx [context](/context).[Context](/context#Context), memberAddress, listAddress [string](/builtin#string), member [mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Member](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Member)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Member](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Member), [error](/builtin#error))
DeleteMember(ctx [context](/context).[Context](/context#Context), memberAddress, listAddress [string](/builtin#string)) [error](/builtin#error)

ListEvents(domain [string](/builtin#string), opts *[ListEventOptions](#ListEventOptions)) *[EventIterator](#EventIterator)
PollEvents(domain [string](/builtin#string), opts *[ListEventOptions](#ListEventOptions)) *[EventPoller](#EventPoller)

ListIPs(ctx [context](/context).[Context](/context#Context), dedicated, enabled [bool](/builtin#bool)) ([][mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[IPAddress](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#IPAddress), [error](/builtin#error))
GetIP(ctx [context](/context).[Context](/context#Context), ip [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[IPAddress](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#IPAddress), [error](/builtin#error))
ListDomainIPs(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string)) ([][mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[IPAddress](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#IPAddress), [error](/builtin#error))
AddDomainIP(ctx [context](/context).[Context](/context#Context), domain, ip [string](/builtin#string)) [error](/builtin#error)
DeleteDomainIP(ctx [context](/context).[Context](/context#Context), domain, ip [string](/builtin#string)) [error](/builtin#error)

ListIPWarmups() *[IPWarmupsIterator](#IPWarmupsIterator)
GetIPWarmup(ctx [context](/context).[Context](/context#Context), ip [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[IPWarmupDetails](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#IPWarmupDetails), [error](/builtin#error))
CreateIPWarmup(ctx [context](/context).[Context](/context#Context), ip [string](/builtin#string)) [error](/builtin#error)
DeleteIPWarmup(ctx [context](/context).[Context](/context#Context), ip [string](/builtin#string)) [error](/builtin#error)

ListExports(ctx [context](/context).[Context](/context#Context), url [string](/builtin#string)) ([][mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Export](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Export), [error](/builtin#error))
GetExport(ctx [context](/context).[Context](/context#Context), id [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Export](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Export), [error](/builtin#error))
GetExportLink(ctx [context](/context).[Context](/context#Context), id [string](/builtin#string)) ([string](/builtin#string), [error](/builtin#error))
CreateExport(ctx [context](/context).[Context](/context#Context), url [string](/builtin#string)) [error](/builtin#error)

GetTagLimits(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[TagLimits](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#TagLimits), [error](/builtin#error))

CreateTemplate(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string), template *[mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Template](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Template)) [error](/builtin#error)
GetTemplate(ctx [context](/context).[Context](/context#Context), domain, name [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Template](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Template), [error](/builtin#error))
UpdateTemplate(ctx [context](/context).[Context](/context#Context), domain [string](/builtin#string), template *[mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[Template](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#Template)) [error](/builtin#error)
DeleteTemplate(ctx [context](/context).[Context](/context#Context), domain, name [string](/builtin#string)) [error](/builtin#error)
ListTemplates(domain [string](/builtin#string), opts *[ListTemplateOptions](#ListTemplateOptions)) *[TemplatesIterator](#TemplatesIterator)

AddTemplateVersion(ctx [context](/context).[Context](/context#Context), domain, templateName [string](/builtin#string), version *[mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[TemplateVersion](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#TemplateVersion)) [error](/builtin#error)
GetTemplateVersion(ctx [context](/context).[Context](/context#Context), domain, templateName, tag [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[TemplateVersion](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#TemplateVersion), [error](/builtin#error))
UpdateTemplateVersion(ctx [context](/context).[Context](/context#Context), domain, templateName [string](/builtin#string), version *[mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[TemplateVersion](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#TemplateVersion)) [error](/builtin#error)
DeleteTemplateVersion(ctx [context](/context).[Context](/context#Context), domain, templateName, tag [string](/builtin#string)) [error](/builtin#error)
ListTemplateVersions(domain, templateName [string](/builtin#string), opts *[ListOptions](#ListOptions)) *[TemplateVersionsIterator](#TemplateVersionsIterator)

ValidateEmail(ctx [context](/context).[Context](/context#Context), email [string](/builtin#string), mailBoxVerify [bool](/builtin#bool)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[ValidateEmailResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#ValidateEmailResponse), [error](/builtin#error))

ListAlertsEvents([context](/context).[Context](/context#Context), *[ListAlertsEventsOptions](#ListAlertsEventsOptions)) (*[mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[AlertsEventsResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#AlertsEventsResponse), [error](/builtin#error))
ListAlerts([context](/context).[Context](/context#Context), *[ListAlertsOptions](#ListAlertsOptions)) (*[mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[AlertsSettingsResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#AlertsSettingsResponse), [error](/builtin#error))
AddAlert([context](/context).[Context](/context#Context), [mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[AlertsEventSettingRequest](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#AlertsEventSettingRequest)) (*[mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[AlertsEventSettingResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#AlertsEventSettingResponse), [error](/builtin#error))
DeleteAlert(ctx [context](/context).[Context](/context#Context), id [uuid](/github.com/google/uuid).[UUID](/github.com/google/uuid#UUID)) [error](/builtin#error)

ListMonitoredDomains(opts [ListMonitoredDomainsOptions](#ListMonitoredDomainsOptions)) (*[MonitoredDomainsIterator](#MonitoredDomainsIterator), [error](/builtin#error))

ListSubaccounts(opts *[ListSubaccountsOptions](#ListSubaccountsOptions)) *[SubaccountsIterator](#SubaccountsIterator)
CreateSubaccount(ctx [context](/context).[Context](/context#Context), subaccountName [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[SubaccountResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#SubaccountResponse), [error](/builtin#error))
GetSubaccount(ctx [context](/context).[Context](/context#Context), subaccountID [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[SubaccountResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#SubaccountResponse), [error](/builtin#error))
EnableSubaccount(ctx [context](/context).[Context](/context#Context), subaccountID [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[SubaccountResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#SubaccountResponse), [error](/builtin#error))
DisableSubaccount(ctx [context](/context).[Context](/context#Context), subaccountID [string](/builtin#string)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[SubaccountResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#SubaccountResponse), [error](/builtin#error))

SetOnBehalfOfSubaccount(subaccountID [string](/builtin#string))
RemoveOnBehalfOfSubaccount()

ListAPIKeys(ctx [context](/context).[Context](/context#Context), opts *[ListAPIKeysOptions](#ListAPIKeysOptions)) ([][mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[APIKey](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#APIKey), [error](/builtin#error))
CreateAPIKey(ctx [context](/context).[Context](/context#Context), role [string](/builtin#string), opts *[CreateAPIKeyOptions](#CreateAPIKeyOptions)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[APIKey](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#APIKey), [error](/builtin#error))
DeleteAPIKey(ctx [context](/context).[Context](/context#Context), id [string](/builtin#string)) [error](/builtin#error)
RegeneratePublicAPIKey(ctx [context](/context).[Context](/context#Context)) ([mtypes](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes).[RegeneratePublicAPIKeyResponse](/github.com/mailgun/mailgun-go/v5@v5.8.1/mtypes#RegeneratePublicAPIKeyResponse), [error](/builtin#error))

}

Mailgun defines the supported subset of the Mailgun API. The Mailgun API may contain additional features which have been deprecated since writing this SDK. This SDK only covers currently supported interface endpoints.

Note that Mailgun reserves the right to deprecate endpoints. Some endpoints listed in this interface may, at any time, become obsolete. Always double-check with the Mailgun API Documentation to determine the currently supported feature set.

Err if an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there are no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

type MetricsIterator struct {

}

Next retrieves the next page of items from the api. Returns false when there are no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

type MimeMessage struct { CommonMessage

}

MimeMessage contains fields relevant to pre-packaged MIME messages.

NewMIMEMessage creates a new MIME message. These messages are largely canned; you do not need to invoke setters to set message-related headers. However, you do still need to call setters for Mailgun-specific settings.

Supports arbitrary-sized recipient lists by automatically sending mail in batches of up to MaxNumberOfRecipients.

To support batch sending, do not provide `to` at this point. You can do this explicitly, or implicitly, as follows:

// Note absence of to parameter(s)! m := NewMIMEMessage(domain, body)

Note that you'll need to invoke the AddRecipientAndVariables or AddRecipient method before sending, though.

func (m *MimeMessage) AddValues(p *FormDataPayload)

func (m *MimeMessage) RecipientCount() int

type MonitoredDomainsIterator added in v5.4.0

type MonitoredDomainsIterator struct {

}

func (*MonitoredDomainsIterator) Err added in v5.4.0

func (*MonitoredDomainsIterator) Next added in v5.4.0

Next retrieves the next page of items from the api. Returns false when there are no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

type PlainMessage struct { CommonMessage

}

PlainMessage contains fields relevant to plain API-synthesized messages. You're expected to use various setters to set most of these attributes, although from, subject, and text are set when the message is created with NewMessage.

func NewMessage(domain, from, subject, text string, to ...string) *PlainMessage

NewMessage returns a new e-mail message with the simplest envelop needed to send.

Supports arbitrary-sized recipient lists by automatically sending mail in batches of up to MaxNumberOfRecipients.

To support batch sending, do not provide `to` at this point. You can do this explicitly, or implicitly, as follows:

// Note absence of to parameter(s)! m := NewMessage("example.com", "me@example.com", "Help save our planet", "Hello world!")

Note that you'll need to invoke the AddRecipientAndVariables or AddRecipient method before sending, though.

AddRecipient appends a receiver to the To: header of a message. It will return an error if the limit of recipients has been exceeded for this message

func (*PlainMessage) AddRecipientAndVariables

AddRecipientAndVariables appends a receiver to the To: header of a message, and as well attaches a set of variables relevant for this recipient. It will return an error if the limit of recipients has been exceeded for this message

func (m *PlainMessage) AddValues(p *FormDataPayload)

func (m *PlainMessage) RecipientCount() int

type Recipient struct { Name string json:"-" Email string json:"-" }

MarshalText satisfies TextMarshaler

UnmarshalText satisfies TextUnmarshaler

If an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

func (ri *RoutesIterator) Offset() int

Offset returns the current offset of the iterator

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

The Specific abstracts the common characteristics between plain text and MIME messages.

If an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Offset returns the current offset of the iterator

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

Err returns any error if one occurred

First returns the first page in the list of tags

Last returns the last page in the list of tags

Next returns the next page in the list of tags

Previous returns the previous page in the list of tags

If an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

If an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

type TrackingOptions struct { Tracking bool TrackingClicks string TrackingOpens bool TrackingPixelLocationTop string }

TrackingOptions contains fields relevant to tracking.

UnexpectedResponseError this error will be returned whenever a Mailgun API returns an error response. Your application can check the Actual field to see the actual HTTP response code returned. URL contains the base URL accessed, sans any query parameters.

Error() performs as String().

String() converts the error into a human-readable, logfmt-compliant string. See http://godoc.org/github.com/kr/logfmt for details on logfmt formatting. TODO(v6): this method is redundant: move into Error(). TODO(v6): this returns `ExpectedOneOf=[]int{200, 201}` but should return `ExpectedOneOf=[200 201]`. Deprecated: use Error() instead.

Err if an error occurred during iteration `Err()` will return non nil

First retrieves the first page of items from the api. Returns false if there was an error. It also sets the iterator object to the first page. Use `.Err()` to retrieve the error.

Last retrieves the last page of items from the api. Calling Last() is invalid unless you first call First() or Next() Returns false if there was an error. It also sets the iterator object to the last page. Use `.Err()` to retrieve the error.

Next retrieves the next page of items from the api. Returns false when there are no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error

Previous retrieves the previous page of items from the api. Returns false when there no more pages to retrieve or if there was an error. Use `.Err()` to retrieve the error if any

type UpdateDomainOptions

type UpdateDomainOptions struct { WebScheme string WebPrefix string RequireTLS *bool SkipVerification *bool UseAutomaticSenderSecurity *bool }

UpdateDomainOptions options for updating a domain