mail

package
v3.2.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2016 License: MIT Imports: 2 Imported by: 0

README

This helper allows you to quickly and easily build a Mail object for sending email through SendGrid.

Dependencies

Quick Start

Run the example (make sure you have set your environment variable to include your SENDGRID_API_KEY).

go run examples/mail/example.go

Usage

Test

go test ./... -v

or

cd helpers/mail
go test -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRequestBody

func GetRequestBody(m *SGMailV3) []byte

Types

type Asm

type Asm struct {
	GroupID         int   `json:"group_id,omitempty"`
	GroupsToDisplay []int `json:"groups_to_display,omitempty"`
}

func NewASM

func NewASM() *Asm

func (*Asm) AddGroupsToDisplay

func (a *Asm) AddGroupsToDisplay(groupsToDisplay ...int) *Asm

func (*Asm) SetGroupID

func (a *Asm) SetGroupID(groupID int) *Asm

type Attachment

type Attachment struct {
	Content     string `json:"content,omitempty"`
	Type        string `json:"type,omitempty"`
	Name        string `json:"name,omitempty"`
	Filename    string `json:"filename,omitempty"`
	Disposition string `json:"disposition,omitempty"`
	ContentID   string `json:"content_id,omitempty"`
}

func NewAttachment

func NewAttachment() *Attachment

func (*Attachment) SetContent

func (a *Attachment) SetContent(content string) *Attachment

func (*Attachment) SetContentID

func (a *Attachment) SetContentID(contentID string) *Attachment

func (*Attachment) SetDisposition

func (a *Attachment) SetDisposition(disposition string) *Attachment

func (*Attachment) SetFilename

func (a *Attachment) SetFilename(filename string) *Attachment

func (*Attachment) SetType

func (a *Attachment) SetType(contentType string) *Attachment

type BccSetting

type BccSetting struct {
	Enable *bool  `json:"enable,omitempty"`
	Email  string `json:"email,omitempty"`
}

func NewBCCSetting

func NewBCCSetting() *BccSetting

func (*BccSetting) SetEmail

func (b *BccSetting) SetEmail(email string) *BccSetting

func (*BccSetting) SetEnable

func (b *BccSetting) SetEnable(enable bool) *BccSetting

type ClickTrackingSetting

type ClickTrackingSetting struct {
	Enable     *bool `json:"enable,omitempty"`
	EnableText *bool `json:"enable_text,omitempty"`
}

func NewClickTrackingSetting

func NewClickTrackingSetting() *ClickTrackingSetting

func (*ClickTrackingSetting) SetEnable

func (c *ClickTrackingSetting) SetEnable(enable bool) *ClickTrackingSetting

func (*ClickTrackingSetting) SetEnableText

func (c *ClickTrackingSetting) SetEnableText(enableText bool) *ClickTrackingSetting

type Content

type Content struct {
	Type  string `json:"type,omitempty"`
	Value string `json:"value,omitempty"`
}

func NewContent

func NewContent(contentType string, value string) *Content

type Email

type Email struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"email,omitempty"`
}

func NewEmail

func NewEmail(name string, address string) *Email

type FooterSetting

type FooterSetting struct {
	Enable *bool  `json:"enable,omitempty"`
	Text   string `json:"text,omitempty"`
	Html   string `json:"html,omitempty"`
}

func NewFooterSetting

func NewFooterSetting() *FooterSetting

func (*FooterSetting) SetEnable

func (f *FooterSetting) SetEnable(enable bool) *FooterSetting

func (*FooterSetting) SetHTML

func (f *FooterSetting) SetHTML(html string) *FooterSetting

func (*FooterSetting) SetText

func (f *FooterSetting) SetText(text string) *FooterSetting

type GaSetting

type GaSetting struct {
	Enable          *bool  `json:"enable,omitempty"`
	CampaignSource  string `json:"utm_source,omitempty"`
	CampaignTerm    string `json:"utm_term,omitempty"`
	CampaignContent string `json:"utm_content,omitempty"`
	CampaignName    string `json:"utm_campaign,omitempty"`
	CampaignMedium  string `json:"utm_medium,omitempty"`
}

func NewGaSetting

func NewGaSetting() *GaSetting

func (*GaSetting) SetCampaignContent

func (g *GaSetting) SetCampaignContent(campaignContent string) *GaSetting

func (*GaSetting) SetCampaignMedium

func (g *GaSetting) SetCampaignMedium(campaignMedium string) *GaSetting

func (*GaSetting) SetCampaignName

func (g *GaSetting) SetCampaignName(campaignName string) *GaSetting

func (*GaSetting) SetCampaignSource

func (g *GaSetting) SetCampaignSource(campaignSource string) *GaSetting

func (*GaSetting) SetCampaignTerm

func (g *GaSetting) SetCampaignTerm(campaignTerm string) *GaSetting

func (*GaSetting) SetEnable

func (g *GaSetting) SetEnable(enable bool) *GaSetting

type MailSettings

type MailSettings struct {
	BCC                  *BccSetting       `json:"bcc,omitempty"`
	BypassListManagement *Setting          `json:"bypass_list_management,omitempty"`
	Footer               *FooterSetting    `json:"footer,omitempty"`
	SandboxMode          *Setting          `json:"sandbox_mode,omitempty"`
	SpamCheckSetting     *SpamCheckSetting `json:"spam_check,omitempty"`
}

func NewMailSettings

func NewMailSettings() *MailSettings

func (*MailSettings) SetBCC

func (m *MailSettings) SetBCC(bcc *BccSetting) *MailSettings

func (*MailSettings) SetBypassListManagement

func (m *MailSettings) SetBypassListManagement(bypassListManagement *Setting) *MailSettings

func (*MailSettings) SetFooter

func (m *MailSettings) SetFooter(footerSetting *FooterSetting) *MailSettings

func (*MailSettings) SetSandboxMode

func (m *MailSettings) SetSandboxMode(sandboxMode *Setting) *MailSettings

func (*MailSettings) SetSpamCheckSettings

func (m *MailSettings) SetSpamCheckSettings(spamCheckSetting *SpamCheckSetting) *MailSettings

type OpenTrackingSetting

type OpenTrackingSetting struct {
	Enable          *bool  `json:"enable,omitempty"`
	SubstitutionTag string `json:"substitution_tag,omitempty"`
}

func NewOpenTrackingSetting

func NewOpenTrackingSetting() *OpenTrackingSetting

func (*OpenTrackingSetting) SetEnable

func (o *OpenTrackingSetting) SetEnable(enable bool) *OpenTrackingSetting

func (*OpenTrackingSetting) SetSubstitutionTag

func (o *OpenTrackingSetting) SetSubstitutionTag(subTag string) *OpenTrackingSetting

type Personalization

type Personalization struct {
	To            []*Email          `json:"to,omitempty"`
	CC            []*Email          `json:"cc,omitempty"`
	BCC           []*Email          `json:"bcc,omitempty"`
	Subject       string            `json:"subject,omitempty"`
	Headers       map[string]string `json:"headers,omitempty"`
	Substitutions map[string]string `json:"substitutions,omitempty"`
	CustomArgs    map[string]string `json:"custom_args,omitempty"`
	Categories    []string          `json:"categories,omitempty"`
	SendAt        int               `json:"send_at,omitempty"`
}

func NewPersonalization

func NewPersonalization() *Personalization

func (*Personalization) AddBCCs

func (p *Personalization) AddBCCs(bcc ...*Email)

func (*Personalization) AddCCs

func (p *Personalization) AddCCs(cc ...*Email)

func (*Personalization) AddTos

func (p *Personalization) AddTos(to ...*Email)

func (*Personalization) SetCustomArg

func (p *Personalization) SetCustomArg(key string, value string)

func (*Personalization) SetHeader

func (p *Personalization) SetHeader(key string, value string)

func (*Personalization) SetSendAt

func (p *Personalization) SetSendAt(sendAt int)

func (*Personalization) SetSubstitution

func (p *Personalization) SetSubstitution(key string, value string)

type SGMailV3

type SGMailV3 struct {
	From             *Email             `json:"from,omitempty"`
	Subject          string             `json:"subject,omitempty"`
	Personalizations []*Personalization `json:"personalizations,omitempty"`
	Content          []*Content         `json:"content,omitempty"`
	Attachments      []*Attachment      `json:"attachments,omitempty"`
	TemplateID       string             `json:"template_id,omitempty"`
	Sections         map[string]string  `json:"sections,omitempty"`
	Headers          map[string]string  `json:"headers,omitempty"`
	Categories       []string           `json:"categories,omitempty"`
	CustomArgs       map[string]string  `json:"custom_args,omitempty"`
	SendAt           int                `json:"send_at,omitempty"`
	BatchID          string             `json:"batch_id,omitempty"`
	Asm              *Asm               `json:"asm,omitempty"`
	IPPoolID         string             `json:"ip_pool_name,omitempty"`
	MailSettings     *MailSettings      `json:"mail_settings,omitempty"`
	TrackingSettings *TrackingSettings  `json:"tracking_settings,omitempty"`
	ReplyTo          *Email             `json:"reply_to,omitempty"`
}

func NewV3Mail

func NewV3Mail() *SGMailV3

func NewV3MailInit

func NewV3MailInit(from *Email, subject string, to *Email, content ...*Content) *SGMailV3

func (*SGMailV3) AddAttachment

func (s *SGMailV3) AddAttachment(a ...*Attachment) *SGMailV3

func (*SGMailV3) AddCategories

func (s *SGMailV3) AddCategories(category ...string) *SGMailV3

func (*SGMailV3) AddContent

func (s *SGMailV3) AddContent(c ...*Content) *SGMailV3

func (*SGMailV3) AddPersonalizations

func (s *SGMailV3) AddPersonalizations(p ...*Personalization) *SGMailV3

func (*SGMailV3) AddSection

func (s *SGMailV3) AddSection(key string, value string) *SGMailV3

func (*SGMailV3) SetASM

func (s *SGMailV3) SetASM(asm *Asm) *SGMailV3

func (*SGMailV3) SetBatchID

func (s *SGMailV3) SetBatchID(batchID string) *SGMailV3

func (*SGMailV3) SetCustomArg

func (s *SGMailV3) SetCustomArg(key string, value string) *SGMailV3

func (*SGMailV3) SetFrom

func (s *SGMailV3) SetFrom(e *Email) *SGMailV3

func (*SGMailV3) SetHeader

func (s *SGMailV3) SetHeader(key string, value string) *SGMailV3

func (*SGMailV3) SetIPPoolID

func (s *SGMailV3) SetIPPoolID(ipPoolID string) *SGMailV3

func (*SGMailV3) SetMailSettings

func (s *SGMailV3) SetMailSettings(mailSettings *MailSettings) *SGMailV3

func (*SGMailV3) SetReplyTo

func (s *SGMailV3) SetReplyTo(e *Email) *SGMailV3

func (*SGMailV3) SetSendAt

func (s *SGMailV3) SetSendAt(sendAt int) *SGMailV3

func (*SGMailV3) SetTemplateID

func (s *SGMailV3) SetTemplateID(templateID string) *SGMailV3

func (*SGMailV3) SetTrackingSettings

func (s *SGMailV3) SetTrackingSettings(trackingSettings *TrackingSettings) *SGMailV3

type SandboxModeSetting

type SandboxModeSetting struct {
	Enable      *bool             `json:"enable,omitempty"`
	ForwardSpam *bool             `json:"forward_spam,omitempty"`
	SpamCheck   *SpamCheckSetting `json:"spam_check,omitempty"`
}

func NewSandboxModeSetting

func NewSandboxModeSetting(enable bool, forwardSpam bool, spamCheck *SpamCheckSetting) *SandboxModeSetting

type Setting

type Setting struct {
	Enable *bool `json:"enable,omitempty"`
}

func NewSetting

func NewSetting(enable bool) *Setting

type SpamCheckSetting

type SpamCheckSetting struct {
	Enable        *bool  `json:"enable,omitempty"`
	SpamThreshold int    `json:"threshold,omitempty"`
	PostToURL     string `json:"post_to_url,omitempty"`
}

func NewSpamCheckSetting

func NewSpamCheckSetting() *SpamCheckSetting

func (*SpamCheckSetting) SetEnable

func (s *SpamCheckSetting) SetEnable(enable bool) *SpamCheckSetting

func (*SpamCheckSetting) SetPostToURL

func (s *SpamCheckSetting) SetPostToURL(postToURL string) *SpamCheckSetting

func (*SpamCheckSetting) SetSpamThreshold

func (s *SpamCheckSetting) SetSpamThreshold(spamThreshold int) *SpamCheckSetting

type SubscriptionTrackingSetting

type SubscriptionTrackingSetting struct {
	Enable          *bool  `json:"enable,omitempty"`
	Text            string `json:"text,omitempty"`
	Html            string `json:"html,omitempty"`
	SubstitutionTag string `json:"substitution_tag,omitempty"`
}

func NewSubscriptionTrackingSetting

func NewSubscriptionTrackingSetting() *SubscriptionTrackingSetting

func (*SubscriptionTrackingSetting) SetEnable

func (*SubscriptionTrackingSetting) SetHTML

func (*SubscriptionTrackingSetting) SetSubstitutionTag

func (s *SubscriptionTrackingSetting) SetSubstitutionTag(subTag string) *SubscriptionTrackingSetting

func (*SubscriptionTrackingSetting) SetText

type TrackingSettings

type TrackingSettings struct {
	ClickTracking        *ClickTrackingSetting        `json:"click_tracking,omitempty"`
	OpenTracking         *OpenTrackingSetting         `json:"open_tracking,omitempty"`
	SubscriptionTracking *SubscriptionTrackingSetting `json:"subscription_tracking,omitempty"`
	GoogleAnalytics      *GaSetting                   `json:"ganalytics,omitempty"`
	BCC                  *BccSetting                  `json:"bcc,omitempty"`
	BypassListManagement *Setting                     `json:"bypass_list_management,omitempty"`
	Footer               *FooterSetting               `json:"footer,omitempty"`
	SandboxMode          *SandboxModeSetting          `json:"sandbox_mode,omitempty"`
}

func NewTrackingSettings

func NewTrackingSettings() *TrackingSettings

func (*TrackingSettings) SetClickTracking

func (t *TrackingSettings) SetClickTracking(clickTracking *ClickTrackingSetting) *TrackingSettings

func (*TrackingSettings) SetGoogleAnalytics

func (t *TrackingSettings) SetGoogleAnalytics(googleAnalytics *GaSetting) *TrackingSettings

func (*TrackingSettings) SetOpenTracking

func (t *TrackingSettings) SetOpenTracking(openTracking *OpenTrackingSetting) *TrackingSettings

func (*TrackingSettings) SetSubscriptionTracking

func (t *TrackingSettings) SetSubscriptionTracking(subscriptionTracking *SubscriptionTrackingSetting) *TrackingSettings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL