mail

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 8 Imported by: 0

README

A GoLang MIME mail library

This is a small GoLang library for composing and sending MIME formatted mails.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QP_Encode

func QP_Encode(s string) string

Quoted-Printable encoding, http://en.wikipedia.org/wiki/Quoted-printable

func Q_Encode

func Q_Encode(s string) string

The "Q" endcoding for message headers, defined in RFC2047 http://tools.ietf.org/html/rfc2047#section-4.2

func Write

func Write(p MIMEPart, buf *bytes.Buffer)

Types

type Address

type Address struct {
	Name, Email string
}

func ToAddress

func ToAddress(s string) Address

func (*Address) String

func (a *Address) String() string

type MIMEAlternative

type MIMEAlternative struct {
	// contains filtered or unexported fields
}

The multipart/alternative subtype indicates that each part is an "alternative" version of the same (or similar) content. The formats are ordered by how faithful they are to the original, with the least faithful first and the most faithful last. Most commonly, multipart/alternative is used for email with two parts, one plain text (text/plain) and one HTML (text/html).

func (*MIMEAlternative) AddPart

func (m *MIMEAlternative) AddPart(p MIMEPart)

func (MIMEAlternative) ContentTransferEncoding

func (m MIMEAlternative) ContentTransferEncoding() string

func (MIMEAlternative) ContentType

func (m MIMEAlternative) ContentType() string

func (MIMEAlternative) EncodedBody

func (m MIMEAlternative) EncodedBody() []byte

func (MIMEAlternative) Headers

func (m MIMEAlternative) Headers() map[string]string

func (*MIMEAlternative) InitBoundary

func (m *MIMEAlternative) InitBoundary()

type MIMEBinary

type MIMEBinary struct {
	Type              string
	Body              []byte
	AdditionalHeaders map[string]string
}

Basic binary data

func (MIMEBinary) ContentTransferEncoding

func (b MIMEBinary) ContentTransferEncoding() string

func (MIMEBinary) ContentType

func (b MIMEBinary) ContentType() string

func (MIMEBinary) EncodedBody

func (b MIMEBinary) EncodedBody() []byte

func (MIMEBinary) Headers

func (b MIMEBinary) Headers() map[string]string

type MIMEHTML

type MIMEHTML string

Basic text/html

func (MIMEHTML) ContentTransferEncoding

func (m MIMEHTML) ContentTransferEncoding() string

func (MIMEHTML) ContentType

func (m MIMEHTML) ContentType() string

func (MIMEHTML) EncodedBody

func (m MIMEHTML) EncodedBody() []byte

func (MIMEHTML) Headers

func (m MIMEHTML) Headers() map[string]string

type MIMEMixed

type MIMEMixed struct {
	// contains filtered or unexported fields
}

Multipart/mixed is used for sending files with different "Content-Type" headers inline, or as attachments.

func (*MIMEMixed) AddPart

func (m *MIMEMixed) AddPart(p MIMEPart)

func (MIMEMixed) ContentTransferEncoding

func (m MIMEMixed) ContentTransferEncoding() string

func (MIMEMixed) ContentType

func (m MIMEMixed) ContentType() string

func (MIMEMixed) EncodedBody

func (m MIMEMixed) EncodedBody() []byte

func (MIMEMixed) Headers

func (m MIMEMixed) Headers() map[string]string

func (*MIMEMixed) InitBoundary

func (m *MIMEMixed) InitBoundary()

type MIMEPart

type MIMEPart interface {
	ContentType() string
	ContentTransferEncoding() string
	EncodedBody() []byte
	Headers() map[string]string
}

Basic MIME part, implmeneted by all subtypes

type MIMEPlain

type MIMEPlain string

Basic text/plain

func (MIMEPlain) ContentTransferEncoding

func (s MIMEPlain) ContentTransferEncoding() string

func (MIMEPlain) ContentType

func (s MIMEPlain) ContentType() string

func (MIMEPlain) EncodedBody

func (s MIMEPlain) EncodedBody() []byte

func (MIMEPlain) Headers

func (s MIMEPlain) Headers() map[string]string

type MIMERelated

type MIMERelated struct {
	// contains filtered or unexported fields
}

Each message part is a component of an aggregate whole. The message consists of a root part which reference other parts inline. Message parts are commonly referenced by the "Content-ID" part header. One common usage of this subtype is to send a web page complete with images, in a single message. The root part would contain the HTML document, and use image tags to reference images stored in the latter parts.

func (*MIMERelated) AddPart

func (m *MIMERelated) AddPart(p MIMEPart)

func (MIMERelated) ContentTransferEncoding

func (m MIMERelated) ContentTransferEncoding() string

func (MIMERelated) ContentType

func (m MIMERelated) ContentType() string

func (MIMERelated) EncodedBody

func (m MIMERelated) EncodedBody() []byte

func (MIMERelated) Headers

func (m MIMERelated) Headers() map[string]string

func (*MIMERelated) InitBoundary

func (m *MIMERelated) InitBoundary()

type Message

type Message struct {
	From    Address
	To      []Address
	Subject string
	Content MIMEPart
	CC      []Address
	BCC     []Address
	Headers map[string]string
}

func (*Message) AllRecipients

func (m *Message) AllRecipients() []string

func (*Message) Send

func (m *Message) Send(config SMTPConfig) error

func (*Message) String

func (m *Message) String() []byte

type SMTPConfig

type SMTPConfig struct {
	Username, Password, Server, Port string
}

func (SMTPConfig) GetSMTPAuth

func (config SMTPConfig) GetSMTPAuth() smtp.Auth

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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