Documentation
¶
Overview ¶
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 at http://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.
Index ¶
- Constants
- Variables
- func GetStatusFromErr(err error) int
- func TimeToFloat(t time.Time) float64
- type AllDomainsKeysIterator
- func (ri *AllDomainsKeysIterator) Err() error
- func (ri *AllDomainsKeysIterator) First(ctx context.Context, items *[]mtypes.DomainKey) bool
- func (ri *AllDomainsKeysIterator) Last(ctx context.Context, items *[]mtypes.DomainKey) bool
- func (ri *AllDomainsKeysIterator) Next(ctx context.Context, items *[]mtypes.DomainKey) bool
- func (ri *AllDomainsKeysIterator) Previous(ctx context.Context, items *[]mtypes.DomainKey) bool
- type BouncesIterator
- func (ci *BouncesIterator) Err() error
- func (ci *BouncesIterator) First(ctx context.Context, items *[]mtypes.Bounce) bool
- func (ci *BouncesIterator) Last(ctx context.Context, items *[]mtypes.Bounce) bool
- func (ci *BouncesIterator) Next(ctx context.Context, items *[]mtypes.Bounce) bool
- func (ci *BouncesIterator) Previous(ctx context.Context, items *[]mtypes.Bounce) bool
- type BufferAttachment
- type Client
- func (mg *Client) APIBase() string
- func (mg *Client) APIKey() string
- func (mg *Client) ActivateDomainKey(ctx context.Context, domain, dkimSelector string) error
- func (mg *Client) AddAlert(ctx context.Context, req mtypes.AlertsEventSettingRequest) (*mtypes.AlertsEventSettingResponse, error)
- func (mg *Client) AddBounce(ctx context.Context, domain, address, code, bounceError string) error
- func (mg *Client) AddBounces(ctx context.Context, domain string, bounces []mtypes.Bounce) error
- func (mg *Client) AddDomainIP(ctx context.Context, domain, ip string) error
- func (mg *Client) AddDomainToMonitoring(ctx context.Context, opts mtypes.AddDomainToMonitoringOptions) (*mtypes.AddDomainToMonitoringResponse, error)
- func (mg *Client) AddOverrideHeader(k, v string)
- func (mg *Client) AddTemplateVersion(ctx context.Context, domain, templateName string, ...) error
- func (mg *Client) ChangeCredentialPassword(ctx context.Context, domain, login, password string) error
- func (mg *Client) CreateAPIKey(ctx context.Context, role string, opts *CreateAPIKeyOptions) (mtypes.APIKey, error)
- func (mg *Client) CreateComplaint(ctx context.Context, domain, address string) error
- func (mg *Client) CreateComplaints(ctx context.Context, domain string, addresses []string) error
- func (mg *Client) CreateCredential(ctx context.Context, domain, login, password string) error
- func (mg *Client) CreateDomain(ctx context.Context, domain string, opts *CreateDomainOptions) (mtypes.GetDomainResponse, error)
- func (mg *Client) CreateDomainKey(ctx context.Context, domain, dkimSelector string, opts *CreateDomainKeyOptions) (mtypes.DomainKey, error)
- func (mg *Client) CreateExport(ctx context.Context, url string) error
- func (mg *Client) CreateIPWarmup(ctx context.Context, ip string) error
- func (mg *Client) CreateMailingList(ctx context.Context, list mtypes.MailingList) (mtypes.MailingList, error)
- func (mg *Client) CreateMember(ctx context.Context, merge bool, listAddress string, member mtypes.Member) error
- func (mg *Client) CreateMemberList(ctx context.Context, u *bool, listAddress string, newMembers []any) error
- func (mg *Client) CreateRoute(ctx context.Context, route mtypes.Route) (_ mtypes.Route, err error)
- func (mg *Client) CreateSubaccount(ctx context.Context, subaccountName string) (mtypes.SubaccountResponse, error)
- func (mg *Client) CreateTemplate(ctx context.Context, domain string, template *mtypes.Template) error
- func (mg *Client) CreateUnsubscribe(ctx context.Context, domain, address, tag string) error
- func (mg *Client) CreateUnsubscribes(ctx context.Context, domain string, unsubscribes []mtypes.Unsubscribe) error
- func (mg *Client) CreateWebhook(ctx context.Context, domain, id string, urls []string) error
- func (mg *Client) DeactivateDomainKey(ctx context.Context, domain, dkimSelector string) error
- func (mg *Client) DeleteAPIKey(ctx context.Context, id string) error
- func (mg *Client) DeleteAlert(ctx context.Context, id uuid.UUID) error
- func (mg *Client) DeleteBounce(ctx context.Context, domain, address string) error
- func (mg *Client) DeleteBounceList(ctx context.Context, domain string) error
- func (mg *Client) DeleteComplaint(ctx context.Context, domain, address string) error
- func (mg *Client) DeleteCredential(ctx context.Context, domain, login string) error
- func (mg *Client) DeleteDomain(ctx context.Context, domain string) error
- func (mg *Client) DeleteDomainIP(ctx context.Context, domain, ip string) error
- func (mg *Client) DeleteDomainKey(ctx context.Context, domain, dkimSelector string) error
- func (mg *Client) DeleteIPWarmup(ctx context.Context, ip string) error
- func (mg *Client) DeleteMailingList(ctx context.Context, address string) error
- func (mg *Client) DeleteMember(ctx context.Context, memberAddress, listAddress string) error
- func (mg *Client) DeleteMonitoredDomain(ctx context.Context, opts mtypes.DeleteMonitoredDomainOptions) error
- func (mg *Client) DeleteRoute(ctx context.Context, id string) error
- func (mg *Client) DeleteTag(ctx context.Context, domain, tag string) error
- func (mg *Client) DeleteTemplate(ctx context.Context, domain, name string) error
- func (mg *Client) DeleteTemplateVersion(ctx context.Context, domain, templateName, tag string) error
- func (mg *Client) DeleteUnsubscribe(ctx context.Context, domain, address string) error
- func (mg *Client) DeleteUnsubscribeWithTag(ctx context.Context, domain, address, tag string) error
- func (mg *Client) DeleteWebhook(ctx context.Context, domain, name string) error
- func (mg *Client) DisableSubaccount(ctx context.Context, subaccountId string) (mtypes.SubaccountResponse, error)
- func (mg *Client) EnableSubaccount(ctx context.Context, subaccountId string) (mtypes.SubaccountResponse, error)
- func (mg *Client) GetBounce(ctx context.Context, domain, address string) (mtypes.Bounce, error)
- func (mg *Client) GetComplaint(ctx context.Context, domain, address string) (mtypes.Complaint, error)
- func (mg *Client) GetDomain(ctx context.Context, domain string, opts *GetDomainOptions) (mtypes.GetDomainResponse, error)
- func (mg *Client) GetDomainConnection(ctx context.Context, domain string) (mtypes.DomainConnection, error)deprecated
- func (mg *Client) GetDomainTracking(ctx context.Context, domain string) (mtypes.DomainTracking, error)
- func (mg *Client) GetExport(ctx context.Context, id string) (mtypes.Export, error)
- func (mg *Client) GetExportLink(ctx context.Context, id string) (string, error)
- func (mg *Client) GetIP(ctx context.Context, ip string) (mtypes.IPAddress, error)
- func (mg *Client) GetIPWarmup(ctx context.Context, ip string) (mtypes.IPWarmupDetails, error)
- func (mg *Client) GetMailingList(ctx context.Context, address string) (mtypes.MailingList, error)
- func (mg *Client) GetMember(ctx context.Context, memberAddress, listAddress string) (mtypes.Member, error)
- func (mg *Client) GetRoute(ctx context.Context, id string) (mtypes.Route, error)
- func (mg *Client) GetStoredAttachment(ctx context.Context, url string) ([]byte, error)
- func (mg *Client) GetStoredMessage(ctx context.Context, url string) (mtypes.StoredMessage, error)
- func (mg *Client) GetStoredMessageRaw(ctx context.Context, url string) (mtypes.StoredMessageRaw, error)
- func (mg *Client) GetSubaccount(ctx context.Context, subaccountID string) (mtypes.SubaccountResponse, error)
- func (mg *Client) GetTag(ctx context.Context, domain, tag string) (mtypes.Tag, error)
- func (mg *Client) GetTagLimits(ctx context.Context, domain string) (mtypes.TagLimits, error)
- func (mg *Client) GetTemplate(ctx context.Context, domain, name string) (mtypes.Template, error)
- func (mg *Client) GetTemplateVersion(ctx context.Context, domain, templateName, tag string) (mtypes.TemplateVersion, error)
- func (mg *Client) GetUnsubscribe(ctx context.Context, domain, address string) (mtypes.Unsubscribe, error)
- func (mg *Client) GetWebhook(ctx context.Context, domain, name string) ([]string, error)
- func (mg *Client) HTTPClient() *http.Client
- func (mg *Client) ListAPIKeys(ctx context.Context, opts *ListAPIKeysOptions) ([]mtypes.APIKey, error)
- func (mg *Client) ListAlerts(ctx context.Context, _ *ListAlertsOptions) (*mtypes.AlertsSettingsResponse, error)
- func (mg *Client) ListAlertsEvents(ctx context.Context, _ *ListAlertsEventsOptions) (*mtypes.AlertsEventsResponse, error)
- func (mg *Client) ListAllDomainsKeys(opts *ListAllDomainsKeysOptions) *AllDomainsKeysIterator
- func (mg *Client) ListBounces(domain string, opts *ListOptions) *BouncesIterator
- func (mg *Client) ListComplaints(domain string, opts *ListOptions) *ComplaintsIterator
- func (mg *Client) ListCredentials(domain string, opts *ListOptions) *CredentialsIterator
- func (mg *Client) ListDomainIPs(ctx context.Context, domain string) ([]mtypes.IPAddress, error)
- func (mg *Client) ListDomainKeys(domain string) *DomainKeysIterator
- func (mg *Client) ListDomains(opts *ListDomainsOptions) *DomainsIterator
- func (mg *Client) ListEvents(domain string, opts *ListEventOptions) *EventIterator
- func (mg *Client) ListExports(ctx context.Context, url string) ([]mtypes.Export, error)
- func (mg *Client) ListIPDomains(ip string, opts *ListIPDomainOptions) *IPDomainsIterator
- func (mg *Client) ListIPWarmups() *IPWarmupsIterator
- func (mg *Client) ListIPs(ctx context.Context, dedicated, enabled bool) ([]mtypes.IPAddress, error)
- func (mg *Client) ListMailingLists(opts *ListOptions) *ListsIterator
- func (mg *Client) ListMembers(listAddress string, opts *ListOptions) *MemberListIterator
- func (mg *Client) ListMetrics(opts MetricsOptions) (*MetricsIterator, error)
- func (mg *Client) ListMonitoredDomains(opts ListMonitoredDomainsOptions) (*MonitoredDomainsIterator, error)
- func (mg *Client) ListRoutes(opts *ListOptions) *RoutesIterator
- func (mg *Client) ListSubaccounts(opts *ListSubaccountsOptions) *SubaccountsIterator
- func (mg *Client) ListTags(domain string, opts *ListTagOptions) *TagIterator
- func (mg *Client) ListTemplateVersions(domain, templateName string, opts *ListOptions) *TemplateVersionsIterator
- func (mg *Client) ListTemplates(domain string, opts *ListTemplateOptions) *TemplatesIterator
- func (mg *Client) ListUnsubscribes(domain string, opts *ListOptions) *UnsubscribesIterator
- func (mg *Client) ListWebhooks(ctx context.Context, domain string) (map[string][]string, error)
- func (mg *Client) PollEvents(domain string, opts *ListEventOptions) *EventPoller
- func (mg *Client) ReSend(ctx context.Context, url string, recipients ...string) (mtypes.SendMessageResponse, error)
- func (mg *Client) RegeneratePublicAPIKey(ctx context.Context) (mtypes.RegeneratePublicAPIKeyResponse, error)
- func (mg *Client) RemoveOnBehalfOfSubaccount()
- func (mg *Client) Send(ctx context.Context, m Message) (mtypes.SendMessageResponse, error)
- func (mg *Client) SetAPIBase(address string) error
- func (mg *Client) SetHTTPClient(c *http.Client)
- func (mg *Client) SetOnBehalfOfSubaccount(subaccountId string)
- func (mg *Client) SetWebhookSigningKey(webhookSigningKey string)
- func (mg *Client) UpdateClickTracking(ctx context.Context, domain, active string) error
- func (mg *Client) UpdateDomain(ctx context.Context, domain string, opts *UpdateDomainOptions) error
- func (mg *Client) UpdateDomainConnection(ctx context.Context, domain string, settings mtypes.DomainConnection) errordeprecated
- func (mg *Client) UpdateDomainDkimAuthority(ctx context.Context, domain string, self bool) (mtypes.UpdateDomainDkimAuthorityResponse, error)
- func (mg *Client) UpdateDomainDkimSelector(ctx context.Context, domain, dkimSelector string) error
- func (mg *Client) UpdateMailingList(ctx context.Context, address string, list mtypes.MailingList) (mtypes.MailingList, error)
- func (mg *Client) UpdateMember(ctx context.Context, memberAddress, listAddress string, member mtypes.Member) (mtypes.Member, error)
- func (mg *Client) UpdateOpenTracking(ctx context.Context, domain, active string) error
- func (mg *Client) UpdateRoute(ctx context.Context, id string, route mtypes.Route) (mtypes.Route, error)
- func (mg *Client) UpdateTemplate(ctx context.Context, domain string, template *mtypes.Template) error
- func (mg *Client) UpdateTemplateVersion(ctx context.Context, domain, templateName string, ...) error
- func (mg *Client) UpdateUnsubscribeTracking(ctx context.Context, domain, active, htmlFooter, textFooter string) error
- func (mg *Client) UpdateWebhook(ctx context.Context, domain, name string, urls []string) error
- func (mg *Client) ValidateEmail(ctx context.Context, email string, mailBoxVerify bool) (mtypes.ValidateEmailResponse, error)
- func (mg *Client) VerifyAndReturnDomain(ctx context.Context, domain string) (mtypes.GetDomainResponse, error)deprecated
- func (mg *Client) VerifyDomain(ctx context.Context, domain string) (mtypes.GetDomainResponse, error)
- func (mg *Client) VerifyWebhookSignature(sig mtypes.Signature) (verified bool, err error)
- func (mg *Client) WebhookSigningKey() string
- type CommonMessage
- func (m *CommonMessage) AddAttachment(attachment string)
- func (m *CommonMessage) AddBufferAttachment(filename string, buffer []byte)
- func (m *CommonMessage) AddDomain(domain string)
- func (m *CommonMessage) AddHeader(header, value string)
- func (m *CommonMessage) AddInline(inline string)
- func (m *CommonMessage) AddReaderAttachment(filename string, readCloser io.ReadCloser)
- func (m *CommonMessage) AddReaderInline(filename string, readCloser io.ReadCloser)
- func (m *CommonMessage) AddTag(tag ...string) error
- func (m *CommonMessage) AddTemplateVariable(variable string, value any) error
- func (m *CommonMessage) AddVariable(variable string, value any) error
- func (m *CommonMessage) Attachments() []string
- func (m *CommonMessage) BufferAttachments() []BufferAttachment
- func (m *CommonMessage) DKIM() *bool
- func (m *CommonMessage) DeliveryTime() time.Time
- func (m *CommonMessage) Domain() string
- func (m *CommonMessage) EnableNativeSend()
- func (m *CommonMessage) EnableTestMode()
- func (m *CommonMessage) Headers() map[string]string
- func (m *CommonMessage) Inlines() []string
- func (m *CommonMessage) NativeSend() bool
- func (m *CommonMessage) ReaderAttachments() []ReaderAttachment
- func (m *CommonMessage) ReaderInlines() []ReaderAttachment
- func (m *CommonMessage) RecipientVariables() map[string]map[string]any
- func (m *CommonMessage) RequireTLS() bool
- func (m *CommonMessage) STOPeriod() string
- func (m *CommonMessage) SecondaryDKIM() string
- func (m *CommonMessage) SecondaryDKIMPublic() string
- func (m *CommonMessage) SetDKIM(dkim bool)
- func (m *CommonMessage) SetDeliveryTime(dt time.Time)
- func (m *CommonMessage) SetReplyTo(recipient string)
- func (m *CommonMessage) SetRequireTLS(b bool)
- func (m *CommonMessage) SetSTOPeriod(stoPeriod string) error
- func (m *CommonMessage) SetSecondaryDKIM(s string)
- func (m *CommonMessage) SetSecondaryDKIMPublic(s string)
- func (m *CommonMessage) SetSkipVerification(b bool)
- func (m *CommonMessage) SetTemplateRenderText(render bool)
- func (m *CommonMessage) SetTemplateVersion(tag string)
- func (m *CommonMessage) SetTracking(tracking bool)
- func (m *CommonMessage) SetTrackingClicks(trackingClicks bool)
- func (m *CommonMessage) SetTrackingOpens(trackingOpens bool)
- func (m *CommonMessage) SetTrackingOptions(options *TrackingOptions)
- func (m *CommonMessage) SkipVerification() bool
- func (m *CommonMessage) Tags() []string
- func (m *CommonMessage) TemplateRenderText() bool
- func (m *CommonMessage) TemplateVariables() map[string]any
- func (m *CommonMessage) TemplateVersionTag() string
- func (m *CommonMessage) TestMode() bool
- func (m *CommonMessage) To() []string
- func (m *CommonMessage) Tracking() *bool
- func (m *CommonMessage) TrackingClicks() *string
- func (m *CommonMessage) TrackingOpens() *bool
- func (m *CommonMessage) TrackingPixelLocationTop() *string
- func (m *CommonMessage) Variables() map[string]string
- type ComplaintsIterator
- func (ci *ComplaintsIterator) Err() error
- func (ci *ComplaintsIterator) First(ctx context.Context, items *[]mtypes.Complaint) bool
- func (ci *ComplaintsIterator) Last(ctx context.Context, items *[]mtypes.Complaint) bool
- func (ci *ComplaintsIterator) Next(ctx context.Context, items *[]mtypes.Complaint) bool
- func (ci *ComplaintsIterator) Previous(ctx context.Context, items *[]mtypes.Complaint) bool
- type CreateAPIKeyOptions
- type CreateDomainKeyOptions
- type CreateDomainOptions
- type CredentialsIterator
- func (ri *CredentialsIterator) Err() error
- func (ri *CredentialsIterator) First(ctx context.Context, items *[]mtypes.Credential) bool
- func (ri *CredentialsIterator) Last(ctx context.Context, items *[]mtypes.Credential) bool
- func (ri *CredentialsIterator) Next(ctx context.Context, items *[]mtypes.Credential) bool
- func (ri *CredentialsIterator) Offset() int
- func (ri *CredentialsIterator) Previous(ctx context.Context, items *[]mtypes.Credential) bool
- type DomainKeysIterator
- func (iter *DomainKeysIterator) Err() error
- func (iter *DomainKeysIterator) First(ctx context.Context, items *[]mtypes.DomainKey) bool
- func (iter *DomainKeysIterator) Last(_ context.Context, _ *[]mtypes.DomainKey) bool
- func (iter *DomainKeysIterator) Next(ctx context.Context, items *[]mtypes.DomainKey) bool
- func (iter *DomainKeysIterator) Previous(_ context.Context, _ *[]mtypes.DomainKey) bool
- type DomainsIterator
- func (ri *DomainsIterator) Err() error
- func (ri *DomainsIterator) First(ctx context.Context, items *[]mtypes.Domain) bool
- func (ri *DomainsIterator) Last(ctx context.Context, items *[]mtypes.Domain) bool
- func (ri *DomainsIterator) Next(ctx context.Context, items *[]mtypes.Domain) bool
- func (ri *DomainsIterator) Offset() int
- func (ri *DomainsIterator) Previous(ctx context.Context, items *[]mtypes.Domain) bool
- type EventIterator
- func (ei *EventIterator) Err() error
- func (ei *EventIterator) First(ctx context.Context, ee *[]events.Event) bool
- func (ei *EventIterator) Last(ctx context.Context, ee *[]events.Event) bool
- func (ei *EventIterator) Next(ctx context.Context, ee *[]events.Event) bool
- func (ei *EventIterator) Previous(ctx context.Context, ee *[]events.Event) bool
- type EventPoller
- type FormDataPayload
- type ForwardedMessage
- type GetDomainOptions
- type IPDomainsIterator
- func (ri *IPDomainsIterator) Err() error
- func (ri *IPDomainsIterator) First(ctx context.Context, items *[]mtypes.DomainIPs) bool
- func (ri *IPDomainsIterator) Last(ctx context.Context, items *[]mtypes.DomainIPs) bool
- func (ri *IPDomainsIterator) Next(ctx context.Context, items *[]mtypes.DomainIPs) bool
- func (ri *IPDomainsIterator) Offset() int
- func (ri *IPDomainsIterator) Previous(ctx context.Context, items *[]mtypes.DomainIPs) bool
- type IPWarmupsIterator
- type ListAPIKeysOptions
- type ListAlertsEventsOptions
- type ListAlertsOptions
- type ListAllDomainsKeysOptions
- type ListDomainsOptions
- type ListEventOptions
- type ListIPDomainOptions
- type ListMonitoredDomainsOptions
- type ListOptions
- type ListSubaccountsOptions
- type ListTagOptions
- type ListTemplateOptions
- type ListsIterator
- func (li *ListsIterator) Err() error
- func (li *ListsIterator) First(ctx context.Context, items *[]mtypes.MailingList) bool
- func (li *ListsIterator) Last(ctx context.Context, items *[]mtypes.MailingList) bool
- func (li *ListsIterator) Next(ctx context.Context, items *[]mtypes.MailingList) bool
- func (li *ListsIterator) Previous(ctx context.Context, items *[]mtypes.MailingList) bool
- type Mailgun
- type MemberListIterator
- func (li *MemberListIterator) Err() error
- func (li *MemberListIterator) First(ctx context.Context, items *[]mtypes.Member) bool
- func (li *MemberListIterator) Last(ctx context.Context, items *[]mtypes.Member) bool
- func (li *MemberListIterator) Next(ctx context.Context, items *[]mtypes.Member) bool
- func (li *MemberListIterator) Previous(ctx context.Context, items *[]mtypes.Member) bool
- type Message
- type MetricsIterator
- type MetricsOptions
- type MimeMessage
- func (*MimeMessage) AddBCC(_ string)
- func (*MimeMessage) AddCC(_ string)
- func (m *MimeMessage) AddRecipient(recipient string) error
- func (m *MimeMessage) AddValues(p *FormDataPayload)
- func (*MimeMessage) Endpoint() string
- func (m *MimeMessage) IsValid() bool
- func (m *MimeMessage) RecipientCount() int
- func (*MimeMessage) SetAmpHTML(_ string)
- func (*MimeMessage) SetHTML(_ string)
- func (*MimeMessage) SetTemplate(_ string)
- type MonitoredDomainsIterator
- type PlainMessage
- func (m *PlainMessage) AddBCC(r string)
- func (m *PlainMessage) AddCC(r string)
- func (m *PlainMessage) AddRecipient(recipient string) error
- func (m *PlainMessage) AddRecipientAndVariables(r string, vars map[string]any) error
- func (m *PlainMessage) AddValues(p *FormDataPayload)
- func (m *PlainMessage) AmpHTML() string
- func (m *PlainMessage) BCC() []string
- func (m *PlainMessage) CC() []string
- func (*PlainMessage) Endpoint() string
- func (m *PlainMessage) From() string
- func (m *PlainMessage) HTML() string
- func (m *PlainMessage) IsValid() bool
- func (m *PlainMessage) RecipientCount() int
- func (m *PlainMessage) SetAmpHTML(h string)
- func (m *PlainMessage) SetHTML(h string)
- func (m *PlainMessage) SetTemplate(t string)
- func (m *PlainMessage) Subject() string
- func (m *PlainMessage) Template() string
- func (m *PlainMessage) Text() string
- type RateLimitedError
- type ReaderAttachment
- type Recipient
- type RoutesIterator
- func (ri *RoutesIterator) Err() error
- func (ri *RoutesIterator) First(ctx context.Context, items *[]mtypes.Route) bool
- func (ri *RoutesIterator) Last(ctx context.Context, items *[]mtypes.Route) bool
- func (ri *RoutesIterator) Next(ctx context.Context, items *[]mtypes.Route) bool
- func (ri *RoutesIterator) Offset() int
- func (ri *RoutesIterator) Previous(ctx context.Context, items *[]mtypes.Route) bool
- type Specific
- type SubaccountsIterator
- func (ri *SubaccountsIterator) Err() error
- func (ri *SubaccountsIterator) First(ctx context.Context, items *[]mtypes.Subaccount) bool
- func (ri *SubaccountsIterator) Last(ctx context.Context, items *[]mtypes.Subaccount) bool
- func (ri *SubaccountsIterator) Next(ctx context.Context, items *[]mtypes.Subaccount) bool
- func (ri *SubaccountsIterator) Offset() int
- func (ri *SubaccountsIterator) Previous(ctx context.Context, items *[]mtypes.Subaccount) bool
- type TagIterator
- func (ti *TagIterator) Err() error
- func (ti *TagIterator) First(ctx context.Context, items *[]mtypes.Tag) bool
- func (ti *TagIterator) Last(ctx context.Context, items *[]mtypes.Tag) bool
- func (ti *TagIterator) Next(ctx context.Context, items *[]mtypes.Tag) bool
- func (ti *TagIterator) Previous(ctx context.Context, items *[]mtypes.Tag) bool
- type TemplateVersionsIterator
- func (li *TemplateVersionsIterator) Err() error
- func (li *TemplateVersionsIterator) First(ctx context.Context, items *[]mtypes.TemplateVersion) bool
- func (li *TemplateVersionsIterator) Last(ctx context.Context, items *[]mtypes.TemplateVersion) bool
- func (li *TemplateVersionsIterator) Next(ctx context.Context, items *[]mtypes.TemplateVersion) bool
- func (li *TemplateVersionsIterator) Previous(ctx context.Context, items *[]mtypes.TemplateVersion) bool
- type TemplatesIterator
- func (ti *TemplatesIterator) Err() error
- func (ti *TemplatesIterator) First(ctx context.Context, items *[]mtypes.Template) bool
- func (ti *TemplatesIterator) Last(ctx context.Context, items *[]mtypes.Template) bool
- func (ti *TemplatesIterator) Next(ctx context.Context, items *[]mtypes.Template) bool
- func (ti *TemplatesIterator) Previous(ctx context.Context, items *[]mtypes.Template) bool
- type TrackingOptions
- type UnexpectedResponseError
- type UnsubscribesIterator
- func (ci *UnsubscribesIterator) Err() error
- func (ci *UnsubscribesIterator) First(ctx context.Context, items *[]mtypes.Unsubscribe) bool
- func (ci *UnsubscribesIterator) Last(ctx context.Context, items *[]mtypes.Unsubscribe) bool
- func (ci *UnsubscribesIterator) Next(ctx context.Context, items *[]mtypes.Unsubscribe) bool
- func (ci *UnsubscribesIterator) Previous(ctx context.Context, items *[]mtypes.Unsubscribe) bool
- type UpdateDomainOptions
Constants ¶
const ( // APIBase - base URL the library uses to contact mailgun. Use SetAPIBase() to override APIBase = "https://api.mailgun.net" APIBaseUS = APIBase APIBaseEU = "https://api.eu.mailgun.net" OnBehalfOfHeader = "X-Mailgun-On-Behalf-Of" )
const MaxNumberOfRecipients = 1000
MaxNumberOfRecipients represents the largest batch of recipients that Mailgun can support in a single API call. This figure includes To:, Cc:, Bcc:, etc. recipients.
const MaxNumberOfTags = 10
MaxNumberOfTags represents the maximum number of tags that can be added for a message
const UserAgent = "mailgun-go/" + Version
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.
const Version = "5.0.0"
Version of current release TODO(vtopc): automate this
Variables ¶
var Debug = false
Debug set true to write the HTTP requests in curl for to stdout
var ErrEmptyParam = errors.New("empty or illegal parameter")
ErrEmptyParam is returned when a required parameter is missing.
var ErrInvalidMessage = errors.New("message not valid")
ErrInvalidMessage is returned by `Send()` when the `mailgun.CommonMessage` struct is incomplete
Functions ¶
func GetStatusFromErr ¶
GetStatusFromErr extracts the http status code from error object
func TimeToFloat ¶
TimeToFloat given time.Time{} return a float64 as given in mailgun event timestamps
Types ¶
type AllDomainsKeysIterator ¶ added in v5.10.0
type AllDomainsKeysIterator struct {
mtypes.ListAllDomainsKeysResponse
// contains filtered or unexported fields
}
AllDomainsKeysIterator is a list iterator for https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/get-v1-dkim-keys
func (*AllDomainsKeysIterator) Err ¶ added in v5.10.0
func (ri *AllDomainsKeysIterator) Err() error
Err if an error occurred during iteration `Err()` will return non nil
func (*AllDomainsKeysIterator) First ¶ added in v5.10.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 (*AllDomainsKeysIterator) Last ¶ added in v5.10.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 (*AllDomainsKeysIterator) Next ¶ added in v5.10.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 BouncesIterator ¶
type BouncesIterator struct {
mtypes.BouncesListResponse
// contains filtered or unexported fields
}
func (*BouncesIterator) Err ¶
func (ci *BouncesIterator) Err() error
Err if an error occurred during iteration `Err()` will return non nil
func (*BouncesIterator) 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 (*BouncesIterator) 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.
type BufferAttachment ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client bundles data needed by a large number of methods in order to interact with the Mailgun API.
func NewMailgunFromEnv ¶
NewMailgunFromEnv returns a new Mailgun client using the environment variables MG_API_KEY, MG_URL, and MG_WEBHOOK_SIGNING_KEY
func (*Client) ActivateDomainKey ¶ added in v5.10.0
ActivateDomainKey deactivates a domain key for the given domain
func (*Client) AddAlert ¶ added in v5.3.0
func (mg *Client) AddAlert(ctx context.Context, req mtypes.AlertsEventSettingRequest, ) (*mtypes.AlertsEventSettingResponse, error)
func (*Client) AddBounce ¶
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.
func (*Client) AddBounces ¶
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
func (mg *Client) AddDomainToMonitoring(ctx context.Context, opts mtypes.AddDomainToMonitoringOptions, ) (*mtypes.AddDomainToMonitoringResponse, error)
AddDomainToMonitoring adds a single domain to an account
func (*Client) AddOverrideHeader ¶
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.
func (*Client) AddTemplateVersion ¶
func (mg *Client) AddTemplateVersion(ctx context.Context, domain, templateName string, version *mtypes.TemplateVersion) error
AddTemplateVersion adds a template version to a template
func (*Client) ChangeCredentialPassword ¶
func (mg *Client) ChangeCredentialPassword(ctx context.Context, domain, login, password string) error
ChangeCredentialPassword attempts to alter the indicated credential's password.
func (*Client) CreateAPIKey ¶ added in v5.5.0
func (*Client) CreateComplaint ¶
CreateComplaint registers the specified address as a recipient who has complained of receiving spam from your domain.
func (*Client) CreateComplaints ¶
func (*Client) CreateCredential ¶
CreateCredential attempts to create associate a new principle with your domain.
func (*Client) CreateDomain ¶
func (mg *Client) CreateDomain(ctx context.Context, domain string, opts *CreateDomainOptions) (mtypes.GetDomainResponse, error)
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.
func (*Client) CreateDomainKey ¶ added in v5.10.0
func (mg *Client) CreateDomainKey(ctx context.Context, domain, dkimSelector string, opts *CreateDomainKeyOptions) (mtypes.DomainKey, error)
CreateDomainKey creates a domain key for the given domain
func (*Client) CreateExport ¶
CreateExport creates an export based on the URL given
func (*Client) CreateIPWarmup ¶ added in v5.8.0
func (*Client) CreateMailingList ¶
func (mg *Client) CreateMailingList(ctx context.Context, list mtypes.MailingList) (mtypes.MailingList, error)
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.
func (*Client) CreateMember ¶
func (mg *Client) CreateMember(ctx context.Context, merge bool, listAddress string, member mtypes.Member) error
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.
func (*Client) CreateMemberList ¶
func (mg *Client) CreateMemberList(ctx context.Context, u *bool, listAddress string, newMembers []any) error
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.
func (*Client) CreateRoute ¶
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.
func (*Client) CreateSubaccount ¶
func (mg *Client) CreateSubaccount(ctx context.Context, subaccountName string) (mtypes.SubaccountResponse, error)
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.
func (*Client) CreateTemplate ¶
func (mg *Client) CreateTemplate(ctx context.Context, domain string, template *mtypes.Template) error
Create a new template which can be used to attach template versions to
func (*Client) CreateUnsubscribe ¶
CreateUnsubscribe adds an e-mail address to the domain's unsubscription table.
func (*Client) CreateUnsubscribes ¶
func (mg *Client) CreateUnsubscribes(ctx context.Context, domain string, unsubscribes []mtypes.Unsubscribe) error
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
func (*Client) CreateWebhook ¶
CreateWebhook installs a new webhook for your domain.
func (*Client) DeactivateDomainKey ¶ added in v5.10.0
DeactivateDomainKey deactivates a domain key for the given domain
func (*Client) DeleteAPIKey ¶ added in v5.5.0
func (*Client) DeleteAlert ¶ added in v5.3.0
func (*Client) DeleteBounce ¶
DeleteBounce removes all bounces associated with the provided e-mail address.
func (*Client) DeleteBounceList ¶
DeleteBounceList removes all bounces in the bounce list
func (*Client) DeleteComplaint ¶
DeleteComplaint removes a previously registered e-mail address from the list of people who complained of receiving spam from your domain.
func (*Client) DeleteCredential ¶
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.
func (*Client) DeleteDomainKey ¶ added in v5.10.0
DeleteDomainKey deletes a domain key from the given domain
func (*Client) DeleteIPWarmup ¶ added in v5.8.0
func (*Client) DeleteMailingList ¶
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.
func (*Client) DeleteMember ¶
DeleteMember removes the member from the list.
func (*Client) DeleteMonitoredDomain ¶ added in v5.4.0
func (mg *Client) DeleteMonitoredDomain(ctx context.Context, opts mtypes.DeleteMonitoredDomainOptions, ) error
DeleteMonitoredDomain deletes a single domain from an account
func (*Client) DeleteRoute ¶
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.
func (*Client) DeleteTag ¶
DeleteTag removes all counters for a particular tag, including the tag itself.
func (*Client) DeleteTemplate ¶
Delete a template given a template name
func (*Client) DeleteTemplateVersion ¶
func (mg *Client) DeleteTemplateVersion(ctx context.Context, domain, templateName, tag string) error
Delete a specific version of a template
func (*Client) DeleteUnsubscribe ¶
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.
func (*Client) DeleteUnsubscribeWithTag ¶
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.
func (*Client) DeleteWebhook ¶
DeleteWebhook removes the specified webhook from your domain's configuration.
func (*Client) DisableSubaccount ¶
func (mg *Client) DisableSubaccount(ctx context.Context, subaccountId string) (mtypes.SubaccountResponse, error)
DisableSubaccount instructs Mailgun to disable subaccount.
func (*Client) EnableSubaccount ¶
func (mg *Client) EnableSubaccount(ctx context.Context, subaccountId string) (mtypes.SubaccountResponse, error)
EnableSubaccount instructs Mailgun to enable subaccount.
func (*Client) GetBounce ¶
GetBounce retrieves a single bounce record, if any exist, for the given recipient address.
func (*Client) GetComplaint ¶
func (mg *Client) GetComplaint(ctx context.Context, domain, address string) (mtypes.Complaint, error)
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 ¶
func (mg *Client) GetDomain(ctx context.Context, domain string, opts *GetDomainOptions) (mtypes.GetDomainResponse, error)
GetDomain retrieves detailed information about the named domain. https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domains/get-v4-domains--name-
func (*Client) GetDomainConnection
deprecated
func (*Client) GetDomainTracking ¶
func (mg *Client) GetDomainTracking(ctx context.Context, domain string) (mtypes.DomainTracking, error)
GetDomainTracking returns tracking settings for a domain
func (*Client) GetExportLink ¶
Download an export by ID. This will respond with a '302 Moved' with the Location header of temporary S3 URL if it is available.
func (*Client) GetIPWarmup ¶ added in v5.8.0
GetIPWarmup retrieves the details of a warmup in progress for the specified IP address
func (*Client) GetMailingList ¶
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.
func (*Client) GetMember ¶
func (mg *Client) GetMember(ctx context.Context, memberAddress, listAddress string) (mtypes.Member, error)
GetMember returns a complete Member structure for a member of a mailing list, given only their subscription e-mail address.
func (*Client) GetRoute ¶
GetRoute retrieves the complete route definition associated with the unique route ID.
func (*Client) GetStoredAttachment ¶
GetStoredAttachment retrieves the raw MIME body of a received e-mail message attachment.
func (*Client) GetStoredMessage ¶
GetStoredMessage retrieves information about a received e-mail message. This provides visibility into, e.g., replies to a message sent to a mailing list.
func (*Client) GetStoredMessageRaw ¶
func (mg *Client) GetStoredMessageRaw(ctx context.Context, url string) (mtypes.StoredMessageRaw, error)
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.
func (*Client) GetSubaccount ¶
func (mg *Client) GetSubaccount(ctx context.Context, subaccountID string) (mtypes.SubaccountResponse, error)
GetSubaccount retrieves detailed information about subaccount using subaccountID.
func (*Client) GetTagLimits ¶
GetTagLimits returns tracking settings for a domain
func (*Client) GetTemplate ¶
GetTemplate gets a template given the template name
func (*Client) GetTemplateVersion ¶
func (mg *Client) GetTemplateVersion(ctx context.Context, domain, templateName, tag string) (mtypes.TemplateVersion, error)
GetTemplateVersion gets a specific version of a template
func (*Client) GetUnsubscribe ¶
func (mg *Client) GetUnsubscribe(ctx context.Context, domain, address string) (mtypes.Unsubscribe, error)
GetUnsubscribe retrieves a single unsubscribe record. Can be used to check if a given address is present in the list of unsubscribed users.
func (*Client) GetWebhook ¶
GetWebhook retrieves the currently assigned webhook URL associated with the provided type of webhook.
func (*Client) HTTPClient ¶
HTTPClient returns the HTTP client configured for this client.
func (*Client) ListAPIKeys ¶ added in v5.5.0
func (*Client) ListAlerts ¶ added in v5.3.0
func (mg *Client) ListAlerts(ctx context.Context, _ *ListAlertsOptions, ) (*mtypes.AlertsSettingsResponse, error)
ListAlerts returns a list of all configured alert settings for your account.
func (*Client) ListAlertsEvents ¶ added in v5.3.0
func (mg *Client) ListAlertsEvents(ctx context.Context, _ *ListAlertsEventsOptions, ) (*mtypes.AlertsEventsResponse, error)
ListAlertsEvents list of events that you can choose to receive alerts for.
func (*Client) ListAllDomainsKeys ¶ added in v5.10.0
func (mg *Client) ListAllDomainsKeys(opts *ListAllDomainsKeysOptions) *AllDomainsKeysIterator
ListAllDomainsKeys retrieves a set of domain keys from Mailgun. https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/get-v1-dkim-keys
func (*Client) ListBounces ¶
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 (*Client) ListComplaints ¶
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 (*Client) ListCredentials ¶
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) ListDomainKeys ¶ added in v5.10.0
func (mg *Client) ListDomainKeys(domain string) *DomainKeysIterator
ListDomainKeys retrieves a set of domain keys from Mailgun. https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/get-v4-domains--authority-name--keys
func (*Client) ListDomains ¶
func (mg *Client) ListDomains(opts *ListDomainsOptions) *DomainsIterator
ListDomains retrieves a set of domains from Mailgun. https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domains/get-v4-domains
func (*Client) ListEvents ¶
func (mg *Client) ListEvents(domain string, opts *ListEventOptions) *EventIterator
ListEvents creates a new iterator to fetch a page of events from the events api
func (*Client) ListExports ¶
ListExports lists all exports created within the past 24 hours
func (*Client) ListIPDomains ¶ added in v5.2.0
func (mg *Client) ListIPDomains(ip string, opts *ListIPDomainOptions) *IPDomainsIterator
ListIPDomains retrieves a list of domains for the specified IP address.
func (*Client) ListIPWarmups ¶ added in v5.8.0
func (mg *Client) ListIPWarmups() *IPWarmupsIterator
ListIPWarmups retrieves a list of warmups in progress in the account
func (*Client) ListIPs ¶
ListIPs returns a list of IPs assigned to your account, including their warmup and assignable to pools status if applicable.
func (*Client) ListMailingLists ¶
func (mg *Client) ListMailingLists(opts *ListOptions) *ListsIterator
ListMailingLists returns the specified set of mailing lists administered by your account.
func (*Client) ListMembers ¶
func (mg *Client) ListMembers(listAddress string, opts *ListOptions) *MemberListIterator
func (*Client) ListMetrics ¶
func (mg *Client) ListMetrics(opts MetricsOptions) (*MetricsIterator, error)
ListMetrics returns domain/account metrics.
To filter by domain:
opts.Filter.BoolGroupAnd = []mailgun.MetricsFilterPredicate{{
Attribute: "domain",
Comparator: "=",
LabeledValues: []mailgun.MetricsLabeledValue{{Label: "example.com", Value: "example.com"}},
}}
https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Metrics/
func (*Client) ListMonitoredDomains ¶ added in v5.4.0
func (mg *Client) ListMonitoredDomains(opts ListMonitoredDomainsOptions) (*MonitoredDomainsIterator, error)
func (*Client) ListRoutes ¶
func (mg *Client) ListRoutes(opts *ListOptions) *RoutesIterator
ListRoutes allows you to iterate through a list of routes returned by the API
func (*Client) ListSubaccounts ¶
func (mg *Client) ListSubaccounts(opts *ListSubaccountsOptions) *SubaccountsIterator
ListSubaccounts retrieves a set of subaccount linked to the primary Mailgun account.
func (*Client) ListTags ¶
func (mg *Client) ListTags(domain string, opts *ListTagOptions) *TagIterator
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 (*Client) ListTemplateVersions ¶
func (mg *Client) ListTemplateVersions(domain, templateName string, opts *ListOptions) *TemplateVersionsIterator
ListTemplateVersions lists all the versions of a specific template
func (*Client) ListTemplates ¶
func (mg *Client) ListTemplates(domain string, opts *ListTemplateOptions) *TemplatesIterator
List all available templates
func (*Client) ListUnsubscribes ¶
func (mg *Client) ListUnsubscribes(domain string, opts *ListOptions) *UnsubscribesIterator
ListUnsubscribes fetches the list of unsubscribes
func (*Client) ListWebhooks ¶
ListWebhooks returns the complete set of webhooks configured for your domain. Note that a zero-length mapping is not an error.
func (*Client) PollEvents ¶
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())
}
func (*Client) ReSend ¶
func (mg *Client) ReSend(ctx context.Context, url string, recipients ...string) (mtypes.SendMessageResponse, error)
ReSend given a storage url resend the stored message to the specified recipients
func (*Client) RegeneratePublicAPIKey ¶ added in v5.5.0
func (*Client) RemoveOnBehalfOfSubaccount ¶
func (mg *Client) RemoveOnBehalfOfSubaccount()
RemoveOnBehalfOfSubaccount remove X-Mailgun-On-Behalf-Of header for primary usage.
func (*Client) Send ¶
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:
- A human-readable status message, typically "Queued. Thank you."
- A Message ID, which is the id used to track the queued message. The message id is useful when contacting support to report an issue with a specific message or to relate a delivered, accepted or failed event back to a specific message.
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
func (*Client) SetAPIBase ¶
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")
func (*Client) SetHTTPClient ¶
SetHTTPClient updates the HTTP client for this client.
func (*Client) SetOnBehalfOfSubaccount ¶
SetOnBehalfOfSubaccount sets X-Mailgun-On-Behalf-Of header to SUBACCOUNT_ACCOUNT_ID in order to perform API request on behalf of subaccount.
func (*Client) SetWebhookSigningKey ¶
SetWebhookSigningKey updates the webhook signing key for this client
func (*Client) UpdateClickTracking ¶
func (*Client) UpdateDomain ¶
UpdateDomain updates a domain's attributes.
func (*Client) UpdateDomainConnection
deprecated
func (*Client) UpdateDomainDkimAuthority ¶ added in v5.10.0
func (*Client) UpdateDomainDkimSelector ¶
UpdateDomainDkimSelector updates the DKIM selector for a domain
func (*Client) UpdateMailingList ¶
func (mg *Client) UpdateMailingList(ctx context.Context, address string, list mtypes.MailingList) (mtypes.MailingList, error)
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.
func (*Client) UpdateMember ¶
func (mg *Client) UpdateMember(ctx context.Context, memberAddress, listAddress string, member mtypes.Member) (mtypes.Member, error)
UpdateMember lets you change certain details about the indicated mailing list member. Address, Name, Vars, and Subscribed fields may be changed.
func (*Client) UpdateOpenTracking ¶
func (*Client) UpdateRoute ¶
func (mg *Client) UpdateRoute(ctx context.Context, id string, route mtypes.Route) (mtypes.Route, error)
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.
func (*Client) UpdateTemplate ¶
func (mg *Client) UpdateTemplate(ctx context.Context, domain string, template *mtypes.Template) error
Update the name and description of a template
func (*Client) UpdateTemplateVersion ¶
func (mg *Client) UpdateTemplateVersion(ctx context.Context, domain, templateName string, version *mtypes.TemplateVersion) error
Update the comment and mark a version of a template active
func (*Client) UpdateUnsubscribeTracking ¶
func (*Client) UpdateWebhook ¶
UpdateWebhook replaces one webhook setting for another.
func (*Client) ValidateEmail ¶
func (mg *Client) ValidateEmail(ctx context.Context, email string, mailBoxVerify bool) (mtypes.ValidateEmailResponse, error)
ValidateEmail performs various checks on the email address provided to ensure it's correctly formatted. It may also be used to break an email address into its sub-components. https://documentation.mailgun.com/docs/inboxready/mailgun-validate/single-valid-ir/
func (*Client) VerifyAndReturnDomain
deprecated
func (mg *Client) VerifyAndReturnDomain(ctx context.Context, domain string) (mtypes.GetDomainResponse, error)
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
func (mg *Client) VerifyDomain(ctx context.Context, domain string) (mtypes.GetDomainResponse, error)
VerifyDomain verifies the domains DNS records (includes A, CNAME, SPF, DKIM and MX records) to ensure the domain is ready and able to send.
func (*Client) VerifyWebhookSignature ¶
VerifyWebhookSignature - use this method to parse the webhook signature given as JSON in the webhook response
func (*Client) WebhookSigningKey ¶
WebhookSigningKey returns the webhook signing key configured for this client
type CommonMessage ¶
type CommonMessage struct {
// contains filtered or unexported fields
}
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 (*CommonMessage) AddAttachment ¶
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 (*CommonMessage) AddBufferAttachment ¶
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 ¶
func (m *CommonMessage) AddDomain(domain string)
AddDomain allows you to use a separate domain for the type of messages you are sending.
func (*CommonMessage) AddHeader ¶
func (m *CommonMessage) AddHeader(header, value string)
AddHeader allows you to send custom MIME headers with the message.
func (*CommonMessage) AddInline ¶
func (m *CommonMessage) AddInline(inline string)
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.
func (*CommonMessage) AddReaderAttachment ¶
func (m *CommonMessage) AddReaderAttachment(filename string, readCloser io.ReadCloser)
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.
func (*CommonMessage) AddReaderInline ¶
func (m *CommonMessage) AddReaderInline(filename string, readCloser io.ReadCloser)
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.
func (*CommonMessage) AddTag ¶
func (m *CommonMessage) AddTag(tag ...string) error
AddTag attaches tags to the message. Tags are useful for metrics gathering and event tracking purposes. Refer to the Mailgun documentation for further details.
func (*CommonMessage) AddTemplateVariable ¶
func (m *CommonMessage) AddTemplateVariable(variable string, value any) error
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.
func (*CommonMessage) AddVariable ¶
func (m *CommonMessage) AddVariable(variable string, value any) error
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 (*CommonMessage) Attachments ¶
func (m *CommonMessage) Attachments() []string
func (*CommonMessage) BufferAttachments ¶
func (m *CommonMessage) BufferAttachments() []BufferAttachment
func (*CommonMessage) DKIM ¶
func (m *CommonMessage) DKIM() *bool
func (*CommonMessage) DeliveryTime ¶
func (m *CommonMessage) DeliveryTime() time.Time
func (*CommonMessage) Domain ¶
func (m *CommonMessage) Domain() string
func (*CommonMessage) EnableNativeSend ¶
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 (*CommonMessage) EnableTestMode ¶
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.
func (*CommonMessage) Headers ¶
func (m *CommonMessage) Headers() map[string]string
Headers retrieve the http headers associated with this message
func (*CommonMessage) Inlines ¶
func (m *CommonMessage) Inlines() []string
func (*CommonMessage) NativeSend ¶
func (m *CommonMessage) NativeSend() bool
func (*CommonMessage) ReaderAttachments ¶
func (m *CommonMessage) ReaderAttachments() []ReaderAttachment
func (*CommonMessage) ReaderInlines ¶
func (m *CommonMessage) ReaderInlines() []ReaderAttachment
func (*CommonMessage) RecipientVariables ¶
func (m *CommonMessage) RecipientVariables() map[string]map[string]any
func (*CommonMessage) RequireTLS ¶
func (m *CommonMessage) RequireTLS() bool
func (*CommonMessage) STOPeriod ¶
func (m *CommonMessage) STOPeriod() string
func (*CommonMessage) SecondaryDKIM ¶ added in v5.10.0
func (m *CommonMessage) SecondaryDKIM() string
func (*CommonMessage) SecondaryDKIMPublic ¶ added in v5.10.0
func (m *CommonMessage) SecondaryDKIMPublic() string
func (*CommonMessage) SetDKIM ¶
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.
func (*CommonMessage) SetDeliveryTime ¶
func (m *CommonMessage) SetDeliveryTime(dt time.Time)
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 (*CommonMessage) SetReplyTo ¶
func (m *CommonMessage) SetReplyTo(recipient string)
SetReplyTo sets the receiver who should receive replies
func (*CommonMessage) SetRequireTLS ¶
func (m *CommonMessage) SetRequireTLS(b bool)
SetRequireTLS information is found in the Mailgun documentation.
func (*CommonMessage) SetSTOPeriod ¶
func (m *CommonMessage) SetSTOPeriod(stoPeriod string) error
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 (*CommonMessage) SetSecondaryDKIM ¶ added in v5.10.0
func (m *CommonMessage) SetSecondaryDKIM(s string)
SetSecondaryDKIM specifies a second domain key to sign the email with. The value is formatted as signing_domain/selector, e.g. example.com/s1.
func (*CommonMessage) SetSecondaryDKIMPublic ¶ added in v5.10.0
func (m *CommonMessage) SetSecondaryDKIMPublic(s string)
SetSecondaryDKIMPublic specifies an alias of the domain key specified in o:secondary-dkim. Also formatted as public_signing_domain/selector. o:secondary-dkim option must also be provided.
func (*CommonMessage) SetSkipVerification ¶
func (m *CommonMessage) SetSkipVerification(b bool)
SetSkipVerification information is found in the Mailgun documentation.
func (*CommonMessage) SetTemplateRenderText ¶
func (m *CommonMessage) SetTemplateRenderText(render bool)
SetTemplateRenderText information is found in the Mailgun documentation.
func (*CommonMessage) SetTemplateVersion ¶
func (m *CommonMessage) SetTemplateVersion(tag string)
SetTemplateVersion information is found in the Mailgun documentation.
func (*CommonMessage) SetTracking ¶
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 (*CommonMessage) SetTrackingClicks ¶
func (m *CommonMessage) SetTrackingClicks(trackingClicks bool)
SetTrackingClicks information is found in the Mailgun documentation.
func (*CommonMessage) SetTrackingOpens ¶
func (m *CommonMessage) SetTrackingOpens(trackingOpens bool)
SetTrackingOpens information is found in the Mailgun documentation.
func (*CommonMessage) SetTrackingOptions ¶
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 (*CommonMessage) SkipVerification ¶
func (m *CommonMessage) SkipVerification() bool
func (*CommonMessage) Tags ¶
func (m *CommonMessage) Tags() []string
func (*CommonMessage) TemplateRenderText ¶
func (m *CommonMessage) TemplateRenderText() bool
func (*CommonMessage) TemplateVariables ¶
func (m *CommonMessage) TemplateVariables() map[string]any
func (*CommonMessage) TemplateVersionTag ¶
func (m *CommonMessage) TemplateVersionTag() string
func (*CommonMessage) TestMode ¶
func (m *CommonMessage) TestMode() bool
func (*CommonMessage) To ¶
func (m *CommonMessage) To() []string
func (*CommonMessage) Tracking ¶
func (m *CommonMessage) Tracking() *bool
func (*CommonMessage) TrackingClicks ¶
func (m *CommonMessage) TrackingClicks() *string
func (*CommonMessage) TrackingOpens ¶
func (m *CommonMessage) TrackingOpens() *bool
func (*CommonMessage) TrackingPixelLocationTop ¶ added in v5.3.0
func (m *CommonMessage) TrackingPixelLocationTop() *string
func (*CommonMessage) Variables ¶
func (m *CommonMessage) Variables() map[string]string
type ComplaintsIterator ¶
type ComplaintsIterator struct {
mtypes.ComplaintsResponse
// contains filtered or unexported fields
}
func (*ComplaintsIterator) Err ¶
func (ci *ComplaintsIterator) Err() error
If an error occurred during iteration `Err()` will return non nil
func (*ComplaintsIterator) 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 (*ComplaintsIterator) 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 (*ComplaintsIterator) 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
type CreateAPIKeyOptions ¶ added in v5.5.0
type CreateDomainKeyOptions ¶ added in v5.10.0
type CreateDomainOptions ¶
type CreateDomainOptions struct {
Password string
SpamAction mtypes.SpamAction
Wildcard bool
ForceDKIMAuthority bool
DKIMKeySize int
IPs []string
WebScheme string
UseAutomaticSenderSecurity bool
ArchiveTo string
DKIMHostName string
DKIMSelector string
ForceRootDKIMHost bool
EncryptIncomingMessage bool
PoolID string
RequireTLS bool
SkipVerification bool
WebPrefix string
MessageTTL int
}
CreateDomainOptions - optional parameters when creating a domain https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Domains/#tag/Domains/operation/POST-v4-domains
type CredentialsIterator ¶
type CredentialsIterator struct {
mtypes.CredentialsListResponse
// contains filtered or unexported fields
}
func (*CredentialsIterator) Err ¶
func (ri *CredentialsIterator) Err() error
If an error occurred during iteration `Err()` will return non nil
func (*CredentialsIterator) First ¶
func (ri *CredentialsIterator) First(ctx context.Context, items *[]mtypes.Credential) bool
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 (*CredentialsIterator) Last ¶
func (ri *CredentialsIterator) Last(ctx context.Context, items *[]mtypes.Credential) bool
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 (*CredentialsIterator) Next ¶
func (ri *CredentialsIterator) Next(ctx context.Context, items *[]mtypes.Credential) bool
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 (*CredentialsIterator) Offset ¶
func (ri *CredentialsIterator) Offset() int
Offset returns the current offset of the iterator
func (*CredentialsIterator) Previous ¶
func (ri *CredentialsIterator) Previous(ctx context.Context, items *[]mtypes.Credential) bool
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 DomainKeysIterator ¶ added in v5.10.0
type DomainKeysIterator struct {
mtypes.ListDomainKeysResponse
// contains filtered or unexported fields
}
DomainKeysIterator is a list iterator for https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys/get-v4-domains--authority-name--keys
TODO(vtopc): implement paging methods: Last and Previous when API will return paging object.
func (*DomainKeysIterator) Err ¶ added in v5.10.0
func (iter *DomainKeysIterator) Err() error
Err if an error occurred during iteration `Err()` will return non nil
func (*DomainKeysIterator) First ¶ added in v5.10.0
First retrieves the first page of items from the API. Returns false if there was an error. Use `.Err()` to retrieve the error.
func (*DomainKeysIterator) Last ¶ added in v5.10.0
Last - not implemented on API. Use Next() instead.
type DomainsIterator ¶
type DomainsIterator struct {
mtypes.ListDomainsResponse
// contains filtered or unexported fields
}
func (*DomainsIterator) Err ¶
func (ri *DomainsIterator) Err() error
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
type EventIterator ¶
EventIterator maintains the state necessary for paging though small parcels of a larger set of events.
func (*EventIterator) Err ¶
func (ei *EventIterator) Err() error
If an error occurred during iteration `Err()` will return non nil
func (*EventIterator) First ¶
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.
func (*EventIterator) Last ¶
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.
type EventPoller ¶
type EventPoller struct {
// contains filtered or unexported fields
}
EventPoller maintains the state necessary for polling events
func (*EventPoller) Err ¶
func (ep *EventPoller) Err() error
If an error occurred during polling `Err()` will return non nil
type FormDataPayload ¶
type FormDataPayload struct {
Values []keyValuePair
Files []keyValuePair
ReadClosers []keyNameRC
Buffers []keyNameBuff
// contains filtered or unexported fields
}
func NewFormDataPayload ¶
func NewFormDataPayload() *FormDataPayload
type ForwardedMessage ¶
type ForwardedMessage struct {
BodyPlain string // body-plain
From string // from
MessageHeaders map[string]string // message-headers
Recipient string // recipient
Sender string // sender
Signature string // signature
StrippedHTML string // stripped-html
StrippedText string // stripped-text
Subject string // subject
Timestamp time.Time // timestamp
Token string // token
}
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
func ExtractForwardedMessage ¶
func ExtractForwardedMessage(formValues url.Values) ForwardedMessage
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 GetDomainOptions ¶
type IPDomainsIterator ¶ added in v5.2.0
type IPDomainsIterator struct {
mtypes.ListIPDomainsResponse
// contains filtered or unexported fields
}
func (*IPDomainsIterator) Err ¶ added in v5.2.0
func (ri *IPDomainsIterator) Err() error
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
type IPWarmupsIterator ¶ added in v5.8.0
type IPWarmupsIterator struct {
mtypes.ListIPWarmupsResponse
// contains filtered or unexported fields
}
func (*IPWarmupsIterator) Err ¶ added in v5.8.0
func (ri *IPWarmupsIterator) Err() error
Err if an error occurred during iteration `Err()` will return non nil
type ListAPIKeysOptions ¶ added in v5.5.0
type ListAlertsEventsOptions ¶ added in v5.3.0
type ListAlertsEventsOptions struct{}
type ListAlertsOptions ¶ added in v5.3.0
type ListAlertsOptions struct{}
type ListAllDomainsKeysOptions ¶ added in v5.10.0
type ListAllDomainsKeysOptions struct {
Limit int // NOTE: currently ignored by Mailgun API
}
type ListDomainsOptions ¶
type ListDomainsOptions struct {
Limit int
// Get only domains with a specific state.
State *mtypes.DomainState
// If sorting is not specified domains are returned in reverse creation date order.
Sort *string
// Get only domains with a specific authority.
Authority *string
// Search domains by the given partial or complete name. Does not support wildcards.
Search *string
// Search on every domain that belongs to any subaccounts under this account.
IncludeSubaccounts *bool
}
type ListEventOptions ¶
type ListEventOptions struct {
// Limits the results to a specific start and end time
Begin, End time.Time
// ForceAscending and ForceDescending are used to force Mailgun to use a given
// traversal order of the events. If both ForceAscending and ForceDescending are
// true, an error will result. If none, the default will be inferred from the Begin
// and End parameters.
ForceAscending, ForceDescending bool
// Compact, if true, compacts the returned JSON to minimize transmission bandwidth.
Compact bool
// Limit caps the number of results returned. If left unspecified, MailGun assumes 100.
Limit int
// Filter allows the caller to provide more specialized filters on the query.
// Consult the Mailgun documentation for more details.
Filter map[string]string
PollInterval time.Duration
}
ListEventOptions modifies the behavior of ListEvents()
type ListIPDomainOptions ¶ added in v5.2.0
type ListIPDomainOptions struct {
Limit int
}
type ListMonitoredDomainsOptions ¶ added in v5.4.0
type ListMonitoredDomainsOptions = inboxready.GETV1InboxreadyDomainsParams
type ListOptions ¶
type ListOptions struct {
Limit int
}
ListOptions used by List methods to specify what list parameters to send to the mailgun API
type ListSubaccountsOptions ¶
type ListTagOptions ¶
type ListTemplateOptions ¶
type ListsIterator ¶
type ListsIterator struct {
mtypes.ListMailingListsResponse
// contains filtered or unexported fields
}
func (*ListsIterator) Err ¶
func (li *ListsIterator) Err() error
Err if an error occurred during iteration `Err()` will return non nil
func (*ListsIterator) First ¶
func (li *ListsIterator) First(ctx context.Context, items *[]mtypes.MailingList) bool
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 (*ListsIterator) Last ¶
func (li *ListsIterator) Last(ctx context.Context, items *[]mtypes.MailingList) bool
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 (*ListsIterator) Next ¶
func (li *ListsIterator) Next(ctx context.Context, items *[]mtypes.MailingList) bool
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 (*ListsIterator) Previous ¶
func (li *ListsIterator) Previous(ctx context.Context, items *[]mtypes.MailingList) bool
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 ¶
type Mailgun interface {
APIBase() string
APIKey() string
HTTPClient() *http.Client
SetHTTPClient(client *http.Client)
SetAPIBase(url string) error
AddOverrideHeader(k string, v string)
// Send attempts to queue a message (see CommonMessage, NewMessage, and its methods) for delivery.
Send(ctx context.Context, m Message) (mtypes.SendMessageResponse, error)
ReSend(ctx context.Context, url string, recipients ...string) (mtypes.SendMessageResponse, error)
ListBounces(domain string, opts *ListOptions) *BouncesIterator
GetBounce(ctx context.Context, domain, address string) (mtypes.Bounce, error)
AddBounce(ctx context.Context, domain, address, code, err string) error
DeleteBounce(ctx context.Context, domain, address string) error
DeleteBounceList(ctx context.Context, domain string) error
ListMetrics(opts MetricsOptions) (*MetricsIterator, error)
GetTag(ctx context.Context, domain, tag string) (mtypes.Tag, error)
DeleteTag(ctx context.Context, domain, tag string) error
ListTags(domain string, opts *ListTagOptions) *TagIterator
ListDomains(opts *ListDomainsOptions) *DomainsIterator
GetDomain(ctx context.Context, domain string, opts *GetDomainOptions) (mtypes.GetDomainResponse, error)
CreateDomain(ctx context.Context, domain string, opts *CreateDomainOptions) (mtypes.GetDomainResponse, error)
VerifyDomain(ctx context.Context, domain string) (mtypes.GetDomainResponse, error)
UpdateDomain(ctx context.Context, domain string, opts *UpdateDomainOptions) error
DeleteDomain(ctx context.Context, domain string) error
// Deprecated: use VerifyDomain instead.
VerifyAndReturnDomain(ctx context.Context, domain string) (mtypes.GetDomainResponse, error)
ListIPDomains(ip string, opts *ListIPDomainOptions) *IPDomainsIterator
// Deprecated: use UpdateDomain instead
UpdateDomainConnection(ctx context.Context, domain string, dc mtypes.DomainConnection) error
// Deprecated: use GetDomain instead
GetDomainConnection(ctx context.Context, domain string) (mtypes.DomainConnection, error)
GetDomainTracking(ctx context.Context, domain string) (mtypes.DomainTracking, error)
UpdateClickTracking(ctx context.Context, domain, active string) error
UpdateUnsubscribeTracking(ctx context.Context, domain, active, htmlFooter, textFooter string) error
UpdateOpenTracking(ctx context.Context, domain, active string) error
ListAllDomainsKeys(opts *ListAllDomainsKeysOptions) *AllDomainsKeysIterator
CreateDomainKey(ctx context.Context, domain, dkimSelector string, opts *CreateDomainKeyOptions) (mtypes.DomainKey, error)
DeleteDomainKey(ctx context.Context, domain, dkimSelector string) error
ActivateDomainKey(ctx context.Context, domain, dkimSelector string) error
ListDomainKeys(domain string) *DomainKeysIterator
DeactivateDomainKey(ctx context.Context, domain, dkimSelector string) error
UpdateDomainDkimAuthority(ctx context.Context, domain string, self bool) (mtypes.UpdateDomainDkimAuthorityResponse, error)
UpdateDomainDkimSelector(ctx context.Context, domain, dkimSelector string) error
GetStoredMessage(ctx context.Context, url string) (mtypes.StoredMessage, error)
GetStoredMessageRaw(ctx context.Context, id string) (mtypes.StoredMessageRaw, error)
GetStoredAttachment(ctx context.Context, url string) ([]byte, error)
ListCredentials(domain string, opts *ListOptions) *CredentialsIterator
CreateCredential(ctx context.Context, domain, login, password string) error
ChangeCredentialPassword(ctx context.Context, domain, login, password string) error
DeleteCredential(ctx context.Context, domain, login string) error
ListUnsubscribes(domain string, opts *ListOptions) *UnsubscribesIterator
GetUnsubscribe(ctx context.Context, domain, address string) (mtypes.Unsubscribe, error)
CreateUnsubscribe(ctx context.Context, domain, address, tag string) error
CreateUnsubscribes(ctx context.Context, domain string, unsubscribes []mtypes.Unsubscribe) error
DeleteUnsubscribe(ctx context.Context, domain, address string) error
DeleteUnsubscribeWithTag(ctx context.Context, domain, address, tag string) error
ListComplaints(domain string, opts *ListOptions) *ComplaintsIterator
GetComplaint(ctx context.Context, domain, address string) (mtypes.Complaint, error)
CreateComplaint(ctx context.Context, domain, address string) error
CreateComplaints(ctx context.Context, domain string, addresses []string) error
DeleteComplaint(ctx context.Context, domain, address string) error
ListRoutes(opts *ListOptions) *RoutesIterator
GetRoute(ctx context.Context, id string) (mtypes.Route, error)
CreateRoute(ctx context.Context, route mtypes.Route) (mtypes.Route, error)
DeleteRoute(ctx context.Context, id string) error
UpdateRoute(ctx context.Context, id string, r mtypes.Route) (mtypes.Route, error)
ListWebhooks(ctx context.Context, domain string) (map[string][]string, error)
CreateWebhook(ctx context.Context, domain, kind string, url []string) error
DeleteWebhook(ctx context.Context, domain, kind string) error
GetWebhook(ctx context.Context, domain, kind string) ([]string, error)
UpdateWebhook(ctx context.Context, domain, kind string, url []string) error
VerifyWebhookSignature(sig mtypes.Signature) (verified bool, err error)
ListMailingLists(opts *ListOptions) *ListsIterator
CreateMailingList(ctx context.Context, ml mtypes.MailingList) (mtypes.MailingList, error)
DeleteMailingList(ctx context.Context, address string) error
GetMailingList(ctx context.Context, address string) (mtypes.MailingList, error)
UpdateMailingList(ctx context.Context, address string, ml mtypes.MailingList) (mtypes.MailingList, error)
ListMembers(listAddress string, opts *ListOptions) *MemberListIterator
GetMember(ctx context.Context, memberAddress, listAddress string) (mtypes.Member, error)
CreateMember(ctx context.Context, merge bool, listAddress string, member mtypes.Member) error
CreateMemberList(ctx context.Context, subscribed *bool, listAddress string, newMembers []any) error
UpdateMember(ctx context.Context, memberAddress, listAddress string, member mtypes.Member) (mtypes.Member, error)
DeleteMember(ctx context.Context, memberAddress, listAddress string) error
ListEvents(domain string, opts *ListEventOptions) *EventIterator
PollEvents(domain string, opts *ListEventOptions) *EventPoller
ListIPs(ctx context.Context, dedicated, enabled bool) ([]mtypes.IPAddress, error)
GetIP(ctx context.Context, ip string) (mtypes.IPAddress, error)
ListDomainIPs(ctx context.Context, domain string) ([]mtypes.IPAddress, error)
AddDomainIP(ctx context.Context, domain, ip string) error
DeleteDomainIP(ctx context.Context, domain, ip string) error
ListIPWarmups() *IPWarmupsIterator
GetIPWarmup(ctx context.Context, ip string) (mtypes.IPWarmupDetails, error)
CreateIPWarmup(ctx context.Context, ip string) error
DeleteIPWarmup(ctx context.Context, ip string) error
ListExports(ctx context.Context, url string) ([]mtypes.Export, error)
GetExport(ctx context.Context, id string) (mtypes.Export, error)
GetExportLink(ctx context.Context, id string) (string, error)
CreateExport(ctx context.Context, url string) error
GetTagLimits(ctx context.Context, domain string) (mtypes.TagLimits, error)
CreateTemplate(ctx context.Context, domain string, template *mtypes.Template) error
GetTemplate(ctx context.Context, domain, name string) (mtypes.Template, error)
UpdateTemplate(ctx context.Context, domain string, template *mtypes.Template) error
DeleteTemplate(ctx context.Context, domain, name string) error
ListTemplates(domain string, opts *ListTemplateOptions) *TemplatesIterator
AddTemplateVersion(ctx context.Context, domain, templateName string, version *mtypes.TemplateVersion) error
GetTemplateVersion(ctx context.Context, domain, templateName, tag string) (mtypes.TemplateVersion, error)
UpdateTemplateVersion(ctx context.Context, domain, templateName string, version *mtypes.TemplateVersion) error
DeleteTemplateVersion(ctx context.Context, domain, templateName, tag string) error
ListTemplateVersions(domain, templateName string, opts *ListOptions) *TemplateVersionsIterator
ValidateEmail(ctx context.Context, email string, mailBoxVerify bool) (mtypes.ValidateEmailResponse, error)
ListAlertsEvents(context.Context, *ListAlertsEventsOptions) (*mtypes.AlertsEventsResponse, error)
ListAlerts(context.Context, *ListAlertsOptions) (*mtypes.AlertsSettingsResponse, error)
AddAlert(context.Context, mtypes.AlertsEventSettingRequest) (*mtypes.AlertsEventSettingResponse, error)
DeleteAlert(ctx context.Context, id uuid.UUID) error
ListMonitoredDomains(opts ListMonitoredDomainsOptions) (*MonitoredDomainsIterator, error)
ListSubaccounts(opts *ListSubaccountsOptions) *SubaccountsIterator
CreateSubaccount(ctx context.Context, subaccountName string) (mtypes.SubaccountResponse, error)
GetSubaccount(ctx context.Context, subaccountID string) (mtypes.SubaccountResponse, error)
EnableSubaccount(ctx context.Context, subaccountID string) (mtypes.SubaccountResponse, error)
DisableSubaccount(ctx context.Context, subaccountID string) (mtypes.SubaccountResponse, error)
SetOnBehalfOfSubaccount(subaccountID string)
RemoveOnBehalfOfSubaccount()
ListAPIKeys(ctx context.Context, opts *ListAPIKeysOptions) ([]mtypes.APIKey, error)
CreateAPIKey(ctx context.Context, role string, opts *CreateAPIKeyOptions) (mtypes.APIKey, error)
DeleteAPIKey(ctx context.Context, id string) error
RegeneratePublicAPIKey(ctx context.Context) (mtypes.RegeneratePublicAPIKeyResponse, 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.
type MemberListIterator ¶
type MemberListIterator struct {
mtypes.MemberListResponse
// contains filtered or unexported fields
}
func (*MemberListIterator) Err ¶
func (li *MemberListIterator) Err() error
Err if an error occurred during iteration `Err()` will return non nil
func (*MemberListIterator) 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 (*MemberListIterator) 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 (*MemberListIterator) Next ¶
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 Message ¶
type Message interface {
Domain() string
To() []string
Tags() []string
DKIM() *bool
SecondaryDKIM() string
SecondaryDKIMPublic() string
DeliveryTime() time.Time
STOPeriod() string
Attachments() []string
ReaderAttachments() []ReaderAttachment
Inlines() []string
ReaderInlines() []ReaderAttachment
BufferAttachments() []BufferAttachment
NativeSend() bool
TestMode() bool
Tracking() *bool
TrackingClicks() *string
TrackingOpens() *bool
TrackingPixelLocationTop() *string
Headers() map[string]string
Variables() map[string]string
TemplateVariables() map[string]any
RecipientVariables() map[string]map[string]any
TemplateVersionTag() string
TemplateRenderText() bool
RequireTLS() bool
SkipVerification() bool
Specific
}
type MetricsIterator ¶
type MetricsIterator struct {
// contains filtered or unexported fields
}
func (*MetricsIterator) Err ¶
func (iter *MetricsIterator) Err() error
func (*MetricsIterator) Next ¶
func (iter *MetricsIterator) Next(ctx context.Context, resp *mtypes.MetricsResponse) (more bool)
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 MetricsOptions ¶
type MetricsOptions = mtypes.MetricsRequest
type MimeMessage ¶
type MimeMessage struct {
CommonMessage
// contains filtered or unexported fields
}
MimeMessage contains fields relevant to pre-packaged MIME messages.
func NewMIMEMessage ¶
func NewMIMEMessage(domain string, body io.ReadCloser, to ...string) *MimeMessage
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 (*MimeMessage) AddBCC ¶
func (*MimeMessage) AddBCC(_ string)
func (*MimeMessage) AddCC ¶
func (*MimeMessage) AddCC(_ string)
func (*MimeMessage) AddRecipient ¶
func (m *MimeMessage) AddRecipient(recipient string) error
func (*MimeMessage) AddValues ¶
func (m *MimeMessage) AddValues(p *FormDataPayload)
func (*MimeMessage) Endpoint ¶
func (*MimeMessage) Endpoint() string
func (*MimeMessage) IsValid ¶
func (m *MimeMessage) IsValid() bool
func (*MimeMessage) RecipientCount ¶
func (m *MimeMessage) RecipientCount() int
func (*MimeMessage) SetAmpHTML ¶
func (*MimeMessage) SetAmpHTML(_ string)
func (*MimeMessage) SetHTML ¶
func (*MimeMessage) SetHTML(_ string)
func (*MimeMessage) SetTemplate ¶
func (*MimeMessage) SetTemplate(_ string)
type MonitoredDomainsIterator ¶ added in v5.4.0
type MonitoredDomainsIterator struct {
// contains filtered or unexported fields
}
func (*MonitoredDomainsIterator) Err ¶ added in v5.4.0
func (iter *MonitoredDomainsIterator) Err() error
func (*MonitoredDomainsIterator) Next ¶ added in v5.4.0
func (iter *MonitoredDomainsIterator) Next(ctx context.Context, resp []mtypes.MonitoredDomain) (more bool)
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 ¶
type PlainMessage struct {
CommonMessage
// contains filtered or unexported fields
}
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 ¶
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", "[email protected]", "Help save our planet", "Hello world!")
Note that you'll need to invoke the AddRecipientAndVariables or AddRecipient method before sending, though.
func (*PlainMessage) AddBCC ¶
func (m *PlainMessage) AddBCC(r string)
func (*PlainMessage) AddCC ¶
func (m *PlainMessage) AddCC(r string)
func (*PlainMessage) AddRecipient ¶
func (m *PlainMessage) AddRecipient(recipient string) error
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 ¶
func (m *PlainMessage) AddRecipientAndVariables(r string, vars map[string]any) error
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 (*PlainMessage) AddValues ¶
func (m *PlainMessage) AddValues(p *FormDataPayload)
func (*PlainMessage) AmpHTML ¶
func (m *PlainMessage) AmpHTML() string
func (*PlainMessage) BCC ¶
func (m *PlainMessage) BCC() []string
func (*PlainMessage) CC ¶
func (m *PlainMessage) CC() []string
func (*PlainMessage) Endpoint ¶
func (*PlainMessage) Endpoint() string
func (*PlainMessage) From ¶
func (m *PlainMessage) From() string
func (*PlainMessage) HTML ¶
func (m *PlainMessage) HTML() string
func (*PlainMessage) IsValid ¶
func (m *PlainMessage) IsValid() bool
func (*PlainMessage) RecipientCount ¶
func (m *PlainMessage) RecipientCount() int
func (*PlainMessage) SetAmpHTML ¶
func (m *PlainMessage) SetAmpHTML(h string)
func (*PlainMessage) SetHTML ¶
func (m *PlainMessage) SetHTML(h string)
func (*PlainMessage) SetTemplate ¶
func (m *PlainMessage) SetTemplate(t string)
func (*PlainMessage) Subject ¶
func (m *PlainMessage) Subject() string
func (*PlainMessage) Template ¶
func (m *PlainMessage) Template() string
func (*PlainMessage) Text ¶
func (m *PlainMessage) Text() string
type RateLimitedError ¶ added in v5.7.0
type RateLimitedError struct {
Err error
ResetAt *time.Time // If provided, the time at which the rate limit will reset.
}
func (*RateLimitedError) Error ¶ added in v5.7.0
func (e *RateLimitedError) Error() string
func (*RateLimitedError) Unwrap ¶ added in v5.7.0
func (e *RateLimitedError) Unwrap() error
type ReaderAttachment ¶
type ReaderAttachment struct {
Filename string
ReadCloser io.ReadCloser
}
type Recipient ¶
func (Recipient) MarshalText ¶
MarshalText satisfies TextMarshaler
func (*Recipient) UnmarshalText ¶
UnmarshalText satisfies TextUnmarshaler
type RoutesIterator ¶
type RoutesIterator struct {
mtypes.RoutesListResponse
// contains filtered or unexported fields
}
func (*RoutesIterator) Err ¶
func (ri *RoutesIterator) Err() error
If an error occurred during iteration `Err()` will return non nil
func (*RoutesIterator) 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 (*RoutesIterator) 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 (*RoutesIterator) 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 (*RoutesIterator) Offset ¶
func (ri *RoutesIterator) Offset() int
Offset returns the current offset of the iterator
type Specific ¶
type Specific interface {
// AddCC appends a receiver to the carbon-copy header of a message.
AddCC(string)
// AddBCC appends a receiver to the blind-carbon-copy header of a message.
AddBCC(string)
// SetHTML If you're sending a message that isn't already MIME encoded, it will arrange to bundle
// an HTML representation of your message in addition to your plain-text body.
SetHTML(string)
// SetAmpHTML If you're sending a message that isn't already MIME encoded, it will arrange to bundle
// an AMP-For-Email representation of your message in addition to your HTML & plain-text content.
SetAmpHTML(string)
// AddValues invoked by Send() to add message-type-specific MIME headers for the API call
// to Mailgun.
AddValues(*FormDataPayload)
// IsValid yields true if and only if the message is valid enough for sending
// through the API.
IsValid() bool
// Endpoint tells Send() which endpoint to use to submit the API call.
Endpoint() string
// RecipientCount returns the total number of recipients for the message.
// This includes To:, Cc:, and Bcc: fields.
//
// NOTE: At present, this method is reliable only for non-MIME messages, as the
// Bcc: and Cc: fields are easily accessible.
// For MIME messages, only the To: field is considered.
// A fix for this issue is planned for a future release.
// For now, MIME messages are always assumed to have 10 recipients between Cc: and Bcc: fields.
// If your MIME messages have more than 10 non-To: field recipients,
// you may find that some recipients will not receive your e-mail.
// It's perfectly OK, of course, for a MIME message to not have any Cc: or Bcc: recipients.
RecipientCount() int
// SetTemplate sets the name of a template stored via the template API.
// See https://documentation.mailgun.com/docs/mailgun/user-manual/sending-messages/#templates
SetTemplate(string)
}
The Specific abstracts the common characteristics between plain text and MIME messages.
type SubaccountsIterator ¶
type SubaccountsIterator struct {
mtypes.ListSubaccountsResponse
// contains filtered or unexported fields
}
func (*SubaccountsIterator) Err ¶
func (ri *SubaccountsIterator) Err() error
If an error occurred during iteration `Err()` will return non nil
func (*SubaccountsIterator) First ¶
func (ri *SubaccountsIterator) First(ctx context.Context, items *[]mtypes.Subaccount) bool
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 (*SubaccountsIterator) Last ¶
func (ri *SubaccountsIterator) Last(ctx context.Context, items *[]mtypes.Subaccount) bool
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 (*SubaccountsIterator) Next ¶
func (ri *SubaccountsIterator) Next(ctx context.Context, items *[]mtypes.Subaccount) bool
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 (*SubaccountsIterator) Offset ¶
func (ri *SubaccountsIterator) Offset() int
Offset returns the current offset of the iterator
func (*SubaccountsIterator) Previous ¶
func (ri *SubaccountsIterator) Previous(ctx context.Context, items *[]mtypes.Subaccount) bool
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 TagIterator ¶
type TagIterator struct {
mtypes.TagsResponse
// contains filtered or unexported fields
}
type TemplateVersionsIterator ¶
type TemplateVersionsIterator struct {
mtypes.TemplateVersionListResp
// contains filtered or unexported fields
}
func (*TemplateVersionsIterator) Err ¶
func (li *TemplateVersionsIterator) Err() error
If an error occurred during iteration `Err()` will return non nil
func (*TemplateVersionsIterator) First ¶
func (li *TemplateVersionsIterator) First(ctx context.Context, items *[]mtypes.TemplateVersion) bool
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 (*TemplateVersionsIterator) Last ¶
func (li *TemplateVersionsIterator) Last(ctx context.Context, items *[]mtypes.TemplateVersion) bool
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 (*TemplateVersionsIterator) Next ¶
func (li *TemplateVersionsIterator) Next(ctx context.Context, items *[]mtypes.TemplateVersion) bool
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 (*TemplateVersionsIterator) Previous ¶
func (li *TemplateVersionsIterator) Previous(ctx context.Context, items *[]mtypes.TemplateVersion) bool
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 TemplatesIterator ¶
type TemplatesIterator struct {
mtypes.ListTemplateResp
// contains filtered or unexported fields
}
func (*TemplatesIterator) Err ¶
func (ti *TemplatesIterator) Err() error
If an error occurred during iteration `Err()` will return non nil
func (*TemplatesIterator) 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 (*TemplatesIterator) 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 (*TemplatesIterator) 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
type TrackingOptions ¶
type TrackingOptions struct {
Tracking bool
TrackingClicks string
TrackingOpens bool
TrackingPixelLocationTop string
}
TrackingOptions contains fields relevant to tracking.
type UnexpectedResponseError ¶
type UnexpectedResponseError struct {
Expected []int
Actual int
Method string
URL string
Data []byte
Header http.Header
}
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.
func (*UnexpectedResponseError) Error ¶
func (e *UnexpectedResponseError) Error() string
Error() performs as String().
func (*UnexpectedResponseError) String
deprecated
func (e *UnexpectedResponseError) String() 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.
type UnsubscribesIterator ¶
type UnsubscribesIterator struct {
mtypes.ListUnsubscribesResponse
// contains filtered or unexported fields
}
func (*UnsubscribesIterator) Err ¶
func (ci *UnsubscribesIterator) Err() error
Err if an error occurred during iteration `Err()` will return non nil
func (*UnsubscribesIterator) First ¶
func (ci *UnsubscribesIterator) First(ctx context.Context, items *[]mtypes.Unsubscribe) bool
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 (*UnsubscribesIterator) Last ¶
func (ci *UnsubscribesIterator) Last(ctx context.Context, items *[]mtypes.Unsubscribe) bool
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 (*UnsubscribesIterator) Next ¶
func (ci *UnsubscribesIterator) Next(ctx context.Context, items *[]mtypes.Unsubscribe) bool
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
func (*UnsubscribesIterator) Previous ¶
func (ci *UnsubscribesIterator) Previous(ctx context.Context, items *[]mtypes.Unsubscribe) bool
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 {
Password string
SpamAction mtypes.SpamAction
Wildcard *bool
WebScheme string
WebPrefix string
RequireTLS *bool
SkipVerification *bool
UseAutomaticSenderSecurity *bool
ArchiveTo string
MailFromHost string
MessageTTL *int
}
UpdateDomainOptions options for updating a domain
Source Files
¶
- alerts.go
- analytics.go
- api_keys.go
- bounces.go
- credentials.go
- domain_keys.go
- domains.go
- domains_connection.go
- domains_tracking.go
- errors.go
- events.go
- exports.go
- http.go
- inboxready_domains.go
- ip_warmups.go
- ips.go
- limits.go
- mailgun.go
- mailing_lists.go
- members.go
- messages.go
- recipients.go
- rest_shim.go
- routes.go
- spam_complaints.go
- stored_messages.go
- subaccounts.go
- tags.go
- template.go
- template_versions.go
- unsubscribes.go
- validation.go
- version.go
- webhooks.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
types/inboxready
Package inboxready provides primitives to interact with the openapi HTTP API.
|
Package inboxready provides primitives to interact with the openapi HTTP API. |
|
Package mtypes contains API Mailgun requests, responses, and helper types.
|
Package mtypes contains API Mailgun requests, responses, and helper types. |