smtpMessage

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT-0 Imports: 9 Imported by: 8

README

MailHedgehog smtp message structure adaptor

Converts smtp message form string value to object and back.

Usage

msg := smtpMessage.FromString(emailString, "")

msg.GetEmail().Subject
smtpMessage.GetEmail().From[0].Name
smtpMessage.GetEmail().From[0].Address

Development

go mod tidy
go mod verify
go mod vendor
go test --cover

Credits

  • Think Studio

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageID

type MessageID string

MessageID represents the ID of an SMTP message

func NewMessageID

func NewMessageID() MessageID

NewMessageID generates a new mail identificatior

type MessagePath

type MessagePath struct {
	Relays  []string
	Mailbox string
	Domain  string
	Params  string
}

MessagePath represents an SMTP "MAIL FROM" or "RCPT TO" string content converted to object.

func MessagePathFromString

func MessagePathFromString(path string) (*MessagePath, error)

MessagePathFromString parses a forward-path or reverse-path into its parts According rfc5321, message path have format "<[RELAYS:]BOX@DOMAIN>[ <EMAIL_PARAMS>]" so all of these examples are possible "<quix@quib.com> <foo,bar>" "<@foo,@bar,@baz:quix@quib.com>" "<@foo,@bar,@baz:quix@quib.com> <foo,bar>"

func (*MessagePath) Address

func (path *MessagePath) Address() string

Address returns full address form path eg: "mailbox@domain".

func (*MessagePath) ToString

func (path *MessagePath) ToString() string

ToString convert path object to standard rfc5321 path string.

type SmtpMessage

type SmtpMessage struct {
	ID   MessageID
	Helo string
	From *MessagePath
	To   []*MessagePath
	// contains filtered or unexported fields
}

SmtpMessage represents parsed SMTP message what allows easily get and manipulate data

func FromString

func FromString(messageString string, messageId MessageID) *SmtpMessage

FromString returns a SmtpMessage from raw message bytes (as output by SmtpMessage.ToReader())

func (*SmtpMessage) GetEmail

func (message *SmtpMessage) GetEmail() *email.Email

GetEmail data object (parsed origin value)

func (*SmtpMessage) GetOrigin

func (message *SmtpMessage) GetOrigin() string

GetOrigin data value (string)

func (*SmtpMessage) SetOrigin

func (message *SmtpMessage) SetOrigin(origin string) error

SetOrigin add to object new Origin Data and automatically parse it to email structure

func (*SmtpMessage) ToReader

func (message *SmtpMessage) ToReader() io.Reader

ToReader returns an io.Reader containing the raw message data

Jump to

Keyboard shortcuts

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