mail

package
v1.15.6 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2025 License: MIT Imports: 30 Imported by: 3

Documentation

Overview

Package mail source https://github.com/jordan-wright/email

Index

Constants

View Source
const (
	MaxLineLength = 76 // MaxLineLength is the maximum line length per RFC 2045

)

Variables

View Source
var ErrMissingBoundary = errors.New("No boundary found for multipart entity")

ErrMissingBoundary is returned when there is no boundary given for a multipart entity

View Source
var ErrMissingContentType = errors.New("No Content-Type found for MIME entity")

ErrMissingContentType is returned when there is no "Content-Type" header for a MIME entity

Functions

func Address added in v1.15.0

func Address(address, name string) mail.Address

func Html added in v1.15.0

func Html(html string) mail.Content

func LoginAuth

func LoginAuth(username, password string) smtp.Auth

func SendMail

func SendMail(config config.Config, subject, html, fromAddress, fromName string, to, cc, bcc, attaches []string) error

Types

type Application

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

func NewApplication added in v1.8.0

func NewApplication(config config.Config, queue queuecontract.Queue) *Application

func (*Application) Attach added in v1.8.0

func (r *Application) Attach(attachments []string) mail.Mail

func (*Application) Bcc added in v1.8.0

func (r *Application) Bcc(bcc []string) mail.Mail

func (*Application) Cc added in v1.8.0

func (r *Application) Cc(cc []string) mail.Mail

func (*Application) Content added in v1.8.0

func (r *Application) Content(content mail.Content) mail.Mail

func (*Application) From added in v1.8.0

func (r *Application) From(address mail.Address) mail.Mail

func (*Application) Queue added in v1.8.0

func (r *Application) Queue(mailable ...mail.Mailable) error

func (*Application) Send added in v1.8.0

func (r *Application) Send(mailable ...mail.Mailable) error

func (*Application) Subject added in v1.15.0

func (r *Application) Subject(subject string) mail.Mail

func (*Application) To added in v1.8.0

func (r *Application) To(to []string) mail.Mail

type Attachment added in v1.14.0

type Attachment struct {
	Filename    string
	ContentType string
	Header      textproto.MIMEHeader
	Content     []byte
	HTMLRelated bool
}

Attachment is a struct representing an email attachment. Based on the mime/multipart.FileHeader struct, Attachment contains the name, MIMEHeader, and content of the attachment in question

type Email

type Email struct {
	ReplyTo     []string
	From        string
	To          []string
	Bcc         []string
	Cc          []string
	Subject     string
	Text        []byte // Plaintext message (optional)
	HTML        []byte // Html message (optional)
	Sender      string // override From as SMTP envelope sender (optional)
	Headers     textproto.MIMEHeader
	Attachments []*Attachment
	ReadReceipt []string
}

Email is the type used for email messages

func NewEmail

func NewEmail() *Email

NewEmail creates an Email, and returns the pointer to it.

func NewEmailFromReader added in v1.14.0

func NewEmailFromReader(r io.Reader) (*Email, error)

NewEmailFromReader reads a stream of bytes from an io.Reader, r, and returns an email struct containing the parsed data. This function expects the data in RFC 5322 format.

func (*Email) Attach

func (e *Email) Attach(r io.Reader, filename string, c string) (a *Attachment, err error)

Attach is used to attach content from an io.Reader to the email. Required parameters include an io.Reader, the desired filename for the attachment, and the Content-Type The function will return the created Attachment for reference, as well as nil for the error, if successful.

func (*Email) AttachFile added in v1.14.0

func (e *Email) AttachFile(filename string) (a *Attachment, err error)

AttachFile is used to attach content to the email. It attempts to open the file referenced by filename and, if successful, creates an Attachment. This Attachment is then appended to the slice of Email.Attachments. The function will then return the Attachment for reference, as well as nil for the error, if successful.

func (*Email) Bytes added in v1.14.0

func (e *Email) Bytes() ([]byte, error)

Bytes converts the Email object to a []byte representation, including all needed MIMEHeaders, boundaries, etc.

func (*Email) Send

func (e *Email) Send(addr string, a smtp.Auth) error

Send an email using the given host and SMTP auth (optional), returns any error thrown by smtp.SendMail This function merges the To, Cc, and Bcc fields and calls the smtp.SendMail function using the Email.Bytes() output as the message

func (*Email) SendWithStartTLS added in v1.14.0

func (e *Email) SendWithStartTLS(addr string, a smtp.Auth, t *tls.Config) error

SendWithStartTLS sends an email over TLS using STARTTLS with an optional TLS config.

The TLS Config is helpful if you need to connect to a host that is used an untrusted certificate.

func (*Email) SendWithTLS added in v1.14.0

func (e *Email) SendWithTLS(addr string, a smtp.Auth, t *tls.Config) error

SendWithTLS sends an email over tls with an optional TLS config.

The TLS Config is helpful if you need to connect to a host that is used an untrusted certificate.

type QueueMail added in v1.15.0

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

func Queue added in v1.15.0

func Queue() *QueueMail

func (*QueueMail) Attachments added in v1.15.0

func (receiver *QueueMail) Attachments() []string

Attachments attach files to the mail

func (*QueueMail) Content added in v1.15.0

func (receiver *QueueMail) Content() *mail.Content

Content set the content of the mail

func (*QueueMail) Envelope added in v1.15.0

func (receiver *QueueMail) Envelope() *mail.Envelope

Envelope set the envelope of the mail

func (*QueueMail) OnConnection added in v1.15.0

func (receiver *QueueMail) OnConnection(connection string) *QueueMail

func (*QueueMail) OnQueue added in v1.15.0

func (receiver *QueueMail) OnQueue(queue string) *QueueMail

func (*QueueMail) Queue added in v1.15.0

func (receiver *QueueMail) Queue() *mail.Queue

Queue set the queue of the mail

type SendMailJob

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

func NewSendMailJob added in v1.12.0

func NewSendMailJob(config config.Config) *SendMailJob

func (*SendMailJob) Handle

func (r *SendMailJob) Handle(args ...any) error

Handle Execute the job.

func (*SendMailJob) Signature

func (r *SendMailJob) Signature() string

Signature The name and signature of the job.

type ServiceProvider

type ServiceProvider struct {
}

func (*ServiceProvider) Boot

func (mail *ServiceProvider) Boot(app foundation.Application)

func (*ServiceProvider) Register

func (mail *ServiceProvider) Register(app foundation.Application)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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