email

package
v0.0.0-...-d7194fd Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package email provides an easy to use and hard to misuse email API

Index

Constants

View Source
const (
	// MaxLineLength is the maximum line length per RFC 2045
	MaxLineLength = 76
)

Variables

View Source
var ErrMissingBoundary = errors.New("No boundary found for multipart entity")

ErrMissingBoundary is returned when there is no boundary given for a multipart entity

View Source
var ErrMissingContentType = errors.New("No Content-Type found for MIME entity")

ErrMissingContentType is returned when there is no "Content-Type" header for a MIME entity

Functions

func InitDefaultMailer

func InitDefaultMailer(config SMTPConfig)

func Send

func Send(email Email) error

Send an email using the default mailer

Types

type Attachment

type Attachment struct {
	Filename string
	Header   textproto.MIMEHeader
	Content  []byte
}

Attachment is an email attachment. Based on the mime/multipart.FileHeader struct, Attachment contains the name, MIMEHeader, and content of the attachment in question

type Email

type Email struct {
	ReplyTo     []*mail.Address
	From        *mail.Address
	To          []*mail.Address
	Bcc         []*mail.Address
	Cc          []*mail.Address
	Subject     string
	Text        []byte // Plaintext message
	HTML        []byte // Html message
	Headers     textproto.MIMEHeader
	Attachments []Attachment
}

Email is an email... either Text or HTML must be provided

func (*Email) Bytes

func (email *Email) Bytes() ([]byte, error)

type Mailer

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

Mailer are used to send email

func NewMailer

func NewMailer(config SMTPConfig) *Mailer

func (*Mailer) Send

func (mailer *Mailer) Send(email Email) error

Send an email

type SMTPConfig

type SMTPConfig struct {
	Host     string
	Port     uint16
	Username string
	Password string
}

SMTPConfig is used to configure an email

Jump to

Keyboard shortcuts

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