email

package
v0.0.0-...-a84335b Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package email implements adapters for sending messages over smtp

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addresses

type Addresses struct {
	From string
	To   []string
}

Addresses supply the supported smtp addresses

func (Addresses) Validate

func (a Addresses) Validate() error

Validate checks that all addresses are likely valid email addresses and all required fields are set

type Message

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

Message is an email body. It collects and formats email messages for transmission

func NewEmail

func NewEmail(addr Addresses, subject, plaintext string) (Message, error)

NewEmail will create a new email message

func (Message) Bytes

func (b Message) Bytes() []byte

Bytes formats the message for transmission according to the https://rfc-editor.org/rfc/rfc822.html spec

func (Message) From

func (b Message) From() string

From returns the From header

func (Message) To

func (b Message) To() []string

To returns the To header

type Sender

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

Sender holds and smtp target config and allows sending to the server.

func NewSender

func NewSender(addr string, opts ...SenderOption) (*Sender, error)

NewSender creates a new Sender instance. addr should contain both the host and port (host:port) values.

func (*Sender) Send

func (s *Sender) Send(body Message) error

Send will attempt to contact the configured smtp server and send the given body. This uses `net/smtp`, so it will attempt to initate TLS and send auth info if configured.

type SenderOption

type SenderOption func(*Sender) error

SenderOption is an optional parameter to NewSender.

func WithPlainAuth

func WithPlainAuth(username, password string) SenderOption

WithPlainAuth adds SMTP Plain Auth credentials to the Sender

Jump to

Keyboard shortcuts

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