smtpclient

package module
v0.0.0-...-22ffe82 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package smtpclient provides an SMTP client with TLS and STARTTLS support, multiple authentication methods (PLAIN, LOGIN, CRAM-MD5), configurable retry with exponential backoff, and multipart email composition with attachments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Filename  string
	Content   io.Reader
	Inline    bool
	ContentID string
}

Attachment represents an email attachment

func AttachFile

func AttachFile(path string) (Attachment, error)

AttachFile opens the file at path and returns an Attachment ready for use in an Email.

type Client

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

Client represents an SMTP client

func New

func New(host string, port int, username, password string, opts ...Option) (*Client, error)

New creates a new SMTP client with required parameters

func (*Client) SendEmail

func (c *Client) SendEmail(ctx context.Context, email Email) error

SendEmail sends an email

type Email

type Email struct {
	From        string
	To          []string
	CC          []string
	BCC         []string
	Subject     string
	HTMLBody    string
	TextBody    string
	Attachments []Attachment
	Headers     map[string]string
}

Email represents an email message

type Option

type Option func(*Client)

Option configures the client

func WithAuthType

func WithAuthType(authType string) Option

WithAuthType sets the authentication type

func WithDebug

func WithDebug() Option

WithDebug enables debug mode

func WithInsecureSkipVerify

func WithInsecureSkipVerify() Option

WithInsecureSkipVerify skips TLS certificate verification (not recommended for production)

func WithRetry

func WithRetry(count int, delay time.Duration) Option

WithRetry configures retry behavior

func WithTLSConfig

func WithTLSConfig(config *tls.Config) Option

WithTLSConfig sets custom TLS configuration

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the connection timeout

func WithoutTLS

func WithoutTLS() Option

WithoutTLS disables TLS/STARTTLS

Jump to

Keyboard shortcuts

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