email

package
v0.0.0-...-b60358c Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: AGPL-3.0 Imports: 16 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)

InitDefaultMailer set the default, global mailer

func IsBlockedTld

func IsBlockedTld(email string) bool

func IsInBlocklist

func IsInBlocklist(email string) bool

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)

Bytes returns the content of the email in the bytes form

type SMTPConfig

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

SMTPConfig is used to configure an email

type SMTPMailer

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

Mailer are used to send email

func NewSMTPMailer

func NewSMTPMailer(config SMTPConfig) SMTPMailer

NewMailer returns a new mailer

func (*SMTPMailer) Send

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

Send an email

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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