mail

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: MIT Imports: 10 Imported by: 0

README

FetchWeb Mail

A Simple SMTP Email API Written in Go

Documentation

Index

Constants

View Source
const (
	MessageTypePlain = "text/plain"
	MessageTypeHTML  = "text/html"
)

Message type constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Email

type Email struct {
	Credentials *EmailCredentials `json:"credentials"`
	Data        *EmailData        `json:"data"`
}

Email represents an email.

func (*Email) Send

func (e *Email) Send() error

Send sends the email.

type EmailAttachment

type EmailAttachment struct {
	Filename string `json:"filename"`
	Data     []byte `json:"data"`
	Inline   bool   `json:"inline"`
}

EmailAttachment represents an email attachment.

type EmailCredentials

type EmailCredentials struct {
	Address  string `json:"address"`
	Hostname string `json:"hostname"`
	Name     string `json:"name"`
	Port     string `json:"port"`
	Password string `json:"password"`
}

EmailCredentials stores the relevant credenial data to send emails.

type EmailData

type EmailData struct {
	From            mail.Address                `json:"from"`
	To              []string                    `json:"to"`
	CC              []string                    `json:"cc"`
	BCC             []string                    `json:"bcc"`
	ReplyTo         string                      `json:"replyto"`
	Subject         string                      `json:"subject"`
	Body            string                      `json:"body"`
	BodyContentType string                      `json:"bodycontenttype"`
	Headers         []Header                    `json:"headers"`
	Attachments     map[string]*EmailAttachment `json:"attachments"`
}

EmailData represents a smtp message.

func (*EmailData) AddAttachment

func (ed *EmailData) AddAttachment(file string, inline bool) error

AddAttachment adds a new attachment to the EmailData.

func (*EmailData) AddHeader

func (ed *EmailData) AddHeader(key string, value string) Header

AddHeader ads a Header to the EmailData.

func (*EmailData) AttachBuffer

func (ed *EmailData) AttachBuffer(filename string, buf []byte, inline bool) error

AttachBuffer attaches a binary attachment to the EmailData.

func (*EmailData) GetRecipients

func (ed *EmailData) GetRecipients() []string

GetRecipients returns all the recipients from the EmailData.

func (*EmailData) ToByteArray

func (ed *EmailData) ToByteArray() []byte

ToByteArray returns all the EmailData as a byte array.

type Header struct {
	Key   string
	Value string
}

Header represents an additional email header.

Jump to

Keyboard shortcuts

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