envelope

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 25 Imported by: 2

Documentation

Index

Constants

View Source
const MimeApplicationOctet = "application/octet-stream"

MimeApplicationOctet is a generic type for binary data when a more specific type is unknown.

View Source
const MimeApplicationPdf = "application/pdf"

MimeApplicationPdf is used for PDF document attachments.

View Source
const MimeApplicationPgpEncrypted = "application/pgp-encrypted"

MimeApplicationPgpEncrypted is found within the multipart/encrypted part, specifying the encryption method for PGP/MIME encrypted messages.

View Source
const MimeApplicationPgpSignature = "application/pgp-signature"

MimeApplicationPgpSignature is used for PGP/MIME digitally signed messages. This contains the digital signature.

View Source
const MimeApplicationPkcs7Mime = "application/pkcs7-mime"

MimeApplicationPkcs7Mime is used for S/MIME encrypted or signed messages.

View Source
const MimeImageGif = "image/gif"

MimeImageGif is used for GIF image attachments or inline images.

View Source
const MimeImageJpeg = "image/jpeg"

MimeImageJpeg is used for JPEG image attachments or inline images.

View Source
const MimeImagePng = "image/png"

MimeImagePng is used for PNG image attachments or inline images.

View Source
const MimeMessageDeliveryStatus = "message/delivery-status"

MimeMessageDeliveryStatus is used for Delivery Status Notifications (DSNs), providing information about the delivery status of an email.

View Source
const MimeMessageDispositionNotification = "message/disposition-notification"

MimeMessageDispositionNotification is used for Message Disposition Notifications (MDNs), indicating the recipient's handling of the message (e.g., displayed, deleted).

View Source
const MimeMessageEmail = "message/rfc822"

MimeMessageEmail (message/rfc822) is used to embed entire email messages as attachments. It includes all headers and the body of the embedded email.

View Source
const MimeMultipartAlternative = "multipart/alternative"

MimeMultipartAlternative is used for presenting the same content in different formats. The client can choose the most appropriate format to display (e.g., plain text or HTML).

View Source
const MimeMultipartEncrypted = "multipart/encrypted"

MimeMultipartEncrypted is used for PGP/MIME encrypted messages. It typically contains two parts: the version information and the encrypted data.

View Source
const MimeMultipartMixed = "multipart/mixed"

MimeMultipartMixed is used for messages with multiple parts of different types. It allows combining different content types in a single message, such as text and attachments.

View Source
const MimeMultipartRelated = "multipart/related"

MimeMultipartRelated is used for messages with inline content, like HTML with embedded images. It groups related parts that should be considered as a single unit.

View Source
const MimeMultipartSigned = "multipart/signed"

MimeMultipartSigned is used for digitally signed emails. It contains two parts: the original message content and the digital signature.

View Source
const MimeTextCalendar = "text/calendar"

MimeTextCalendar is used for iCalendar data, allowing the inclusion of calendar events.

View Source
const MimeTextEnriched = "text/enriched"

MimeTextEnriched is an obsolete format for rich text, predating HTML in emails.

View Source
const MimeTextHtml = "text/html"

MimeTextHtml is used for HTML-formatted content, allowing rich text and formatting.

View Source
const MimeTextPlain = "text/plain"

MimeTextPlain is used for plain text content without any formatting.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachmentPart added in v0.3.7

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

func (*AttachmentPart) Filename added in v0.3.7

func (a *AttachmentPart) Filename() (string, error)

type Content added in v0.3.7

type Content struct {
	Headers  textproto.MIMEHeader
	Body     []byte
	Children []Content
}

func (*Content) AsAttachment added in v0.3.7

func (c *Content) AsAttachment() (*AttachmentPart, error)

func (*Content) AsForm added in v0.3.7

func (c *Content) AsForm() (*FormPart, error)

func (*Content) AsInline added in v0.3.7

func (c *Content) AsInline() (*InlinePart, error)

func (*Content) Decode added in v0.3.7

func (c *Content) Decode() ([]byte, error)

func (*Content) Encoding added in v0.3.7

func (c *Content) Encoding() string

func (*Content) Flatten added in v0.3.7

func (c *Content) Flatten() []*Content

func (*Content) IsAttachment added in v0.3.7

func (c *Content) IsAttachment() bool

func (*Content) IsForm added in v0.3.7

func (c *Content) IsForm() bool

func (*Content) IsInline added in v0.3.7

func (c *Content) IsInline() bool

func (*Content) Leaf added in v0.3.7

func (c *Content) Leaf() bool

func (*Content) Walk added in v0.3.7

func (c *Content) Walk(fn func(*Content, int) error) error

type Data

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

func (*Data) Bytes

func (d *Data) Bytes() []byte

func (*Data) Len

func (d *Data) Len() int

func (*Data) Prepend

func (d *Data) Prepend(p []byte) (n int, err error)

func (*Data) PrependString

func (d *Data) PrependString(s string) (n int, err error)

func (*Data) ReadFrom

func (d *Data) ReadFrom(r io.Reader) (n int64, err error)

func (*Data) Reader

func (d *Data) Reader() io.Reader

func (*Data) String

func (d *Data) String() string

func (*Data) Write

func (d *Data) Write(p []byte) (n int, err error)

func (*Data) WriteString

func (d *Data) WriteString(s string) (n int, err error)

type DecodingOption added in v0.4.0

type DecodingOption func(*decodingConfig)

func WithLiteral added in v0.4.0

func WithLiteral() DecodingOption

WithLiteral will not encode the headers to utf-8, just read them as MIMEHeader

func WithQuoteEscape added in v0.4.0

func WithQuoteEscape(headers ...string) DecodingOption

func WithQuoteNone added in v0.4.0

func WithQuoteNone() DecodingOption

type Envelope

type Envelope struct {

	// Remote IP address
	RemoteAddr net.Addr

	// Message sent in EHLO command
	Helo string

	// TLS is true if the email was received using a TLS connection
	TLS bool

	// UTF8
	UTF8 bool

	// ESMTP: true if EHLO was used
	ESMTP bool

	// Sender
	MailFrom *mail.Address

	// Recipients
	RcptTo []*mail.Address

	// Data stores the header and message body
	Data *Data
	// contains filtered or unexported fields
}

Envelope of Email represents a single SMTP message.

func NewEnvelope

func NewEnvelope(remoteAddr net.Addr, connectionId uint64) *Envelope

func (*Envelope) ConnectionId

func (e *Envelope) ConnectionId() uint64

func (*Envelope) Context

func (e *Envelope) Context() context.Context

func (*Envelope) EnvelopeId

func (e *Envelope) EnvelopeId() string

func (*Envelope) GetError

func (e *Envelope) GetError() error

func (*Envelope) Mail

func (e *Envelope) Mail() (*Mail, error)

Mail will "Open" the envelope and return the mail inside it. Ie the Header and Body

func (*Envelope) PrependHeader

func (e *Envelope) PrependHeader(key, value string) error

PrependHeader adds a header to Data in the envelope, operates on the Data buffer

func (*Envelope) SetError

func (e *Envelope) SetError(err error)

func (*Envelope) WithContext

func (e *Envelope) WithContext(ctx context.Context)

type FormPart added in v0.3.7

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

func (*FormPart) Filename added in v0.3.7

func (a *FormPart) Filename() (string, error)

func (*FormPart) Name added in v0.3.7

func (a *FormPart) Name() (string, error)

type Headers added in v0.3.7

type Headers struct {
	textproto.MIMEHeader
}

func (Headers) From added in v0.3.7

func (h Headers) From() (*mail.Address, error)

func (Headers) To added in v0.3.7

func (h Headers) To() ([]*mail.Address, error)

type InlinePart added in v0.3.7

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

func (*InlinePart) Filename added in v0.3.7

func (a *InlinePart) Filename() (string, error)

type Mail

type Mail struct {
	UTF8 bool

	RawHeaders []byte
	RawBody    []byte
}

func NewMail added in v0.3.7

func NewMail(data []byte, utf8 bool) (*Mail, error)

NewMail returns a new mail struct. It takes in a byte slice of the entire email contant. ie. header + body eg

From: sender@example.com
To: recipient@example.com
Subject: Test Email
Content-Type: text/plain

This is a test email body.

func (*Mail) Body

func (e *Mail) Body() (*Content, error)

func (*Mail) Headers

func (e *Mail) Headers(options ...DecodingOption) (Headers, error)

Headers parses the headers from Envelope to a human-readable format.

Jump to

Keyboard shortcuts

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