Documentation ¶
Overview ¶
Package raweml allows you to send emails with Priority and Conversation Topic using the AWS SES raw email.
Index ¶
- func Send(email Email) error
- type Attachment
- type ChildBlock
- type Email
- func (email Email) Bytes() ([]byte, error)
- func (email Email) GetHeaders() *textproto.MIMEHeader
- func (email Email) GetSendRawEmailInput() (*ses.SendRawEmailInput, error)
- func (email Email) GetSource() *string
- func (email Email) Send() (*ses.SendRawEmailOutput, error)
- func (email Email) SendWithSession(svc *ses.SES, input *ses.SendRawEmailInput) (result *ses.SendRawEmailOutput, err error)
- func (email *Email) SetHeader(key, value string)
- type EmailPriority
- type Filetime
- type Recipients
- type Thread
- func (thread *Thread) AddChildBlock()
- func (thread Thread) Bytes() (r []byte)
- func (thread Thread) GUIDBytes() []byte
- func (thread Thread) GetGUID() uuid.UUID
- func (thread Thread) GetTopic() string
- func (thread Thread) Index() string
- func (thread *Thread) Reference() string
- func (thread Thread) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attachment ¶
type Attachment struct { Name string // Name of the attachment Data io.Reader // reader for the attachment. WARNING do not set this value to a nil *bytes.Buffer it will not be same as nil io.Reader and it will cause panic. FileName string // Name must be set to a valid fully qulified file name. If the FileName is set the Data reader will be ignored. ContentID string // Optional. Used for embedding images into the email (e.g. <img src="cid:{{ContentID}}">) ContentType string // Optional. When blank falls back to 'application/octet-stream'. }
Attachment represents an email attachment.
type ChildBlock ¶
type ChildBlock struct { TimeFlag bool TimeDifference int64 // Unix NanoSecond RandomNum byte SequenceCount byte }
ChildBlock represents a sub thread of the email thread
- TimeFlag: 1 bit 0 when TimeDiff < 0.02s && TimeDiff > 2 years; 1 when TimeDiff < 1s && TimeDiff > 56 years)
- TimeDifference: time difference between the child block create time and the time in the header block expressed in FILETIME units if TimeFlag = 0 : discard high 15 bits and low 18 bits if TimeFlag = 1 : discard high 10 bits and low 32 bits
- RandomNum: random number gernerated by calling GetTickCount()
- SequenceCount: default set to 0 (Four bits containing a sequence count that is taken from part of the random number.)
func NewChildBlock ¶
func NewChildBlock(deltaTimeUxNs int64) (r ChildBlock)
NewChildBlock creates a child header block
func ParseChildBlock ¶
func ParseChildBlock(blockString string) (block ChildBlock, err error)
ParseChildBlock converts string to a ChildBlock struct
func (ChildBlock) Bytes ¶
func (block ChildBlock) Bytes() []byte
Bytes returns bits representing the Child block : 40 bits: 1 flag, 31 time diff, 4 random, 4 seq
func (ChildBlock) String ¶
func (block ChildBlock) String() string
String returns the base64 encoded string of the header child block
type Email ¶
type Email struct { From string Recipients Recipients Feedback string // feedback destination email address. If left blank "Return-path" or "From" address will be used instead. Subject string // to change subject Charset use the MIME encoded-word syntax (e.g. "=?utf-8?B?5L2g5aW9?=") (ref: https://docs.aws.amazon.com/ses/latest/dg/send-email-raw.html) TextBody string HTMLBody string CharSet string Attachments []Attachment // set it to `nil` if there are no attachments Headers textproto.MIMEHeader Priority EmailPriority Topic string InReplyTo string // Message-ID of the email to reply to in order for the email to be threaded. Gmail requires direct connection between emails to be threaded. Outlook is using Thread-Index and Thread-Topic instead AwsRegion string // AWS Region of the SES service }
Email is the structure containing all email details. To send the email just call the Send() method.
func (Email) GetHeaders ¶
func (email Email) GetHeaders() *textproto.MIMEHeader
GetHeaders returns a pointer to the email.Headers field
func (Email) GetSendRawEmailInput ¶
func (email Email) GetSendRawEmailInput() (*ses.SendRawEmailInput, error)
GetSendRawEmailInput converts the email to *ses.SendRawEmailInput structure required by ses.SendRawEmail() method
func (Email) SendWithSession ¶
func (email Email) SendWithSession(svc *ses.SES, input *ses.SendRawEmailInput) (result *ses.SendRawEmailOutput, err error)
SendWithSession sends the email using provided svc session
type EmailPriority ¶
type EmailPriority string
EmailPriority defines the type of priorty for the email
const ( PriorityHigh EmailPriority = "High" PriorityNormal EmailPriority = "Normal" PriorityLow EmailPriority = "Low" )
Email Priority Types
func (EmailPriority) String ¶
func (priority EmailPriority) String() string
String converts email priority to string
func (EmailPriority) ToNumber ¶
func (priority EmailPriority) ToNumber() string
ToNumber converts email priority to a string number
type Filetime ¶
type Filetime struct { // -------------------------- // Generic file time stamp : // -------------------------- // 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 // |<------ year ------>|<- month ->|<---- day --->| |<--- hour --->|<---- minute --->|<- second/2 ->| // // Offset Length Contents // 0 7 bits year years since 1980 // 7 4 bits month [1..12] // 11 5 bits day [1..31] // 16 5 bits hour [0..23] // 21 6 bits minite [0..59] // 27 5 bits second/2 [0..29] // -------------------------- // ref: https://golang.org/src/syscall/types_windows.go LowDateTime uint32 HighDateTime uint32 }
Filetime represents the date and time for a file. It is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC) This is different from Unix time which is the number of nanoseconds elapsed since January 1, 1970, 00:00:00 (UTC)
func UnixNanoToFiletime ¶
UnixNanoToFiletime converts nano seconds to Filetime
func (*Filetime) UnixNanoseconds ¶
UnixNanoseconds returns Filetime in nanoseconds since Epoch (00:00:00 UTC, January 1, 1970).
type Recipients ¶
type Recipients struct { BccAddresses []*string `type:"list"` CcAddresses []*string `type:"list"` ToAddresses []*string `type:"list"` // contains filtered or unexported fields }
Recipients contains list of To, Cc, Bcc recipients
func NewRecipients ¶
func NewRecipients(to string, cc string, bcc string) (r Recipients)
NewRecipients converts comma separated list of to, cc and bcc into Recipients structure
func (Recipients) All ¶
func (r Recipients) All() []*string
All returns all recipients as an array of string pointers
func (Recipients) Bcc ¶
func (r Recipients) Bcc() string
Bcc returns a string of comma separated Bcc recipients
func (Recipients) Cc ¶
func (r Recipients) Cc() string
Cc returns a string of comma separated Cc recipients
func (Recipients) IsEmpty ¶
func (r Recipients) IsEmpty() bool
IsEmpty returns true if there are no recipients in any of To, Cc or Bcc
func (Recipients) String ¶
func (r Recipients) String() string
String converts Recipients structure to a string with comma separated recipients
func (Recipients) To ¶
func (r Recipients) To() string
To returns a string of comma separated To recipients
type Thread ¶
type Thread struct { DateUnixNano int64 // Thread Date in Unix Nanoseconds ChildBlocks []ChildBlock // Sub-Thread // contains filtered or unexported fields }
Thread represents an email thread (conversation group)
func NewEmailThreadFromParams ¶
func NewEmailThreadFromParams(dateUnixNanoSec int64, guid uuid.UUID, topic string, childBlocks []ChildBlock) (r Thread)
NewEmailThreadFromParams creates a new Thread struct from arguments
func ParseEmailThread ¶
ParseEmailThread creates thread based on the idx and topic
func (*Thread) AddChildBlock ¶
func (thread *Thread) AddChildBlock()
AddChildBlock ads a child block to the emails thread
func (Thread) Index ¶
Index is an alias for String() function that returns the thread as Base64 encoded string