mailer

package
v0.0.0-...-552a5ab Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SmtpAuthPlain = "PLAIN"
	SmtpAuthLogin = "LOGIN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mailer

type Mailer interface {
	// Send sends an email with the provided Message.
	Send(message *Message) error
}

Mailer defines a base mail client interface.

type Message

type Message struct {
	From        mail.Address         `json:"from"`
	To          []mail.Address       `json:"to"`
	Bcc         []mail.Address       `json:"bcc"`
	Cc          []mail.Address       `json:"cc"`
	Subject     string               `json:"subject"`
	HTML        string               `json:"html"`
	Text        string               `json:"text"`
	Headers     map[string]string    `json:"headers"`
	Attachments map[string]io.Reader `json:"attachments"`
}

Message defines a generic email message struct.

type Sendmail

type Sendmail struct {
}

Sendmail implements mailer.Mailer interface and defines a mail client that sends emails via the "sendmail" *nix command.

This client is usually recommended only for development and testing.

func (*Sendmail) Send

func (c *Sendmail) Send(m *Message) error

Send implements `mailer.Mailer` interface.

type SmtpClient

type SmtpClient struct {
	Host     string
	Port     int
	Username string
	Password string
	Tls      bool

	// SMTP auth method to use
	// (if not explicitly set, defaults to "PLAIN")
	AuthMethod string

	// LocalName is optional domain name used for the EHLO/HELO exchange
	// (if not explicitly set, defaults to "localhost").
	//
	// This is required only by some SMTP servers, such as Gmail SMTP-relay.
	LocalName string
}

SmtpClient defines a SMTP mail client structure that implements `mailer.Mailer` interface.

func NewSmtpClient deprecated

func NewSmtpClient(
	host string,
	port int,
	username string,
	password string,
	tls bool,
) *SmtpClient

Deprecated: Use directly the SmtpClient struct literal.

NewSmtpClient creates new SmtpClient with the provided configuration.

func (*SmtpClient) Send

func (c *SmtpClient) Send(m *Message) error

Send implements `mailer.Mailer` interface.

Jump to

Keyboard shortcuts

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