mail

package
v0.1.73 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 18 Imported by: 2

Documentation

Overview

https://github.com/scorredoira/email

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Receipt

func Receipt(name, address string) *mail.Address

Types

type Attachment

type Attachment struct {
	Filename  string
	Path      string
	Bytes     []byte
	ContentID string
}

Attachment represents an email attachment

type ContentType

type ContentType int

ContentType represents content type

const (
	// TextPlain sets body type to text/plain in message body
	TextPlain ContentType = iota
	// TextHTML sets body type to text/html in message body
	TextHTML
)

func (ContentType) String

func (contentType ContentType) String() string

type Dialer

type Dialer struct {
	Server   string
	Port     int
	TLS      bool
	Account  string
	Password string
	Timeout  time.Duration
}

Dialer is a dialer to an SMTP server.

func (*Dialer) Dial

func (d *Dialer) Dial() (client *smtp.Client, err error)

func (*Dialer) Send

func (d *Dialer) Send(msg ...*Message) error

Send sends the given messages.

func (*Dialer) SendMail

func (d *Dialer) SendMail(ctx context.Context, from string, to []string, msg []byte) error

SendMail connects to the server at Dialer's addr, switches to TLS if possible, authenticates with the optional mechanism a if possible, and then sends an email from address from, to addresses to, with message msg.

The addresses in the to parameter are the SMTP RCPT addresses.

The msg parameter should be an RFC 822-style email with headers first, a blank line, and then the message body. The lines of msg should be CRLF terminated. The msg headers should usually include fields such as "From", "To", "Subject", and "Cc". Sending "Bcc" messages is accomplished by including an email address in the to parameter but not including it in the msg headers.

type Message

type Message struct {
	From        *mail.Address
	To, Cc, Bcc Receipts
	Subject     string
	Body        string
	ContentType ContentType
	Attachments []*Attachment
}

Message represents an email message

func (*Message) Bytes

func (m *Message) Bytes(id string) []byte

func (*Message) RcptList

func (m *Message) RcptList() (rcpts []string)

type Receipts

type Receipts []*mail.Address

func ParseReceipts

func ParseReceipts(rcpts string) (Receipts, error)

func (Receipts) List

func (rcpts Receipts) List() []string

func (Receipts) MarshalJSON

func (rcpts Receipts) MarshalJSON() ([]byte, error)

func (Receipts) MarshalText

func (rcpts Receipts) MarshalText() ([]byte, error)

func (Receipts) String

func (rcpts Receipts) String() string

func (*Receipts) UnmarshalJSON

func (rcpts *Receipts) UnmarshalJSON(b []byte) error

func (*Receipts) UnmarshalText

func (rcpts *Receipts) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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