emailer

package
v0.0.0-...-acaa9d6 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2017 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MAIL_SERVER = "localhost"
	MAIL_PORT   = 25

	LINE_MAX_LEN = 500 // for splitting encoded attachment data

	// templates for generating the message components
	ADDRESS    = "\"{{.DisplayName}}\" <{{.Address}}>"
	HEADERS    = "" /* 150-byte string literal not displayed */
	BODY       = "" /* 392-byte string literal not displayed */
	ATTACHMENT = "" /* 208-byte string literal not displayed */

	// message body mime types
	TEXT_MIME = "text/plain"
	HTML_MIME = "text/html"
)

Variables

This section is empty.

Functions

func GenerateAddress

func GenerateAddress(context *EmailAddress) (string, error)

func GenerateAttachment

func GenerateAttachment(attachment *EmailAttachment) (string, error)

func GenerateBody

func GenerateBody(messageText, messageHtml, boundary string) (string, error)

func GenerateBoundary

func GenerateBoundary() string

GenerateBoundary produces a random string that can be used for the email multipart boundary marker

func GenerateHeaders

func GenerateHeaders(sender, recipient, subject, boundary string) (string, error)

func IsPossibleEmail

func IsPossibleEmail(email string) bool

Use a basic regex to confirm the given is plausibly an email address

func Send

func Send(subject, messageText, messageHtml string, sender, recipient *EmailAddress, attachments []*EmailAttachment) error

Send transmits the given message, with optional attachments, via the default mail server (localhost) and port (25)

func SendFromServer

func SendFromServer(subject, messageText, messageHtml, server string, sender, recipient *EmailAddress, attachments []*EmailAttachment, port int) error

SendFromServer transmits the given message, with optional attachments, via the defined mail server and port

Types

type EmailAddress

type EmailAddress struct {
	DisplayName string
	Address     string
}

type EmailAttachment

type EmailAttachment struct {
	ContentType     string
	EncodedFileData string
	Boundary        string
	// read content from a file
	FileLocation string
	FileName     string
	// or provide it here
	Contents string
}

type EmailBody

type EmailBody struct {
	MessageText     string
	MessageHtml     string
	Boundary        string
	RelatedBoundary string
	AltBoundary     string
}

type EmailHeaders

type EmailHeaders struct {
	Sender    string
	Recipient string
	Subject   string
	Boundary  string
}

Jump to

Keyboard shortcuts

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