emailer

package
v0.0.0-...-73d7af2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	// Name is the filename of the attachment.
	Name string
	// Data holds the binary content of the attachment.
	Data []byte
}

Attachment represents a file attachment to be sent with an email.

type Emailer

type Emailer interface {
	// Send sends an email with the provided details.
	//
	// Parameters:
	//   toName:    The recipient's name.
	//   to:        The recipient's email address.
	//   subject:   The email subject.
	//   content:   The email body content (can include HTML).
	//   attachments: A slice of Attachment objects to include with the email.
	//
	// Returns an error if sending fails.
	Send(toName string, to string, subject string, content string, attachments []Attachment) error
}

Emailer defines an interface for sending emails. Implementations should handle constructing and sending emails with optional attachments.

type SendgridApiMail

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

SendgridApiMail implements the Emailer interface using SendGrid's API.

func NewSendgridApiMail

func NewSendgridApiMail(apiKey, fromName, from string) *SendgridApiMail

NewSendgridApiMail creates a new SendgridApiMail instance with the provided API key and sender information.

func (*SendgridApiMail) Send

func (s *SendgridApiMail) Send(toName, to, subject, content string, attachments []Attachment) error

Send sends an email using the SendGrid API. It builds a V3Mail object with the given recipient details, subject, content, and attachments.

type SmtpMail

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

SmtpMail implements the Emailer interface using an SMTP server.

func NewSmtpMail

func NewSmtpMail(hostname string, port int, username string, password string, smtpHelo string, noTLSCheck bool, auth string, fromName, from string, encryption string) *SmtpMail

NewSmtpMail returns a new instance of SmtpMail configured with the provided parameters.

func (*SmtpMail) Send

func (s *SmtpMail) Send(toName, to, subject, content string, attachments []Attachment) error

Send sends an email with the specified details and attachments via SMTP.

Jump to

Keyboard shortcuts

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