email

package
v0.0.0-...-0751618 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SenderHeader    = "From:"
	RecipientHeader = "To:"
	SubjectHeader   = "Subject:"
)

Variables

View Source
var (
	ErrSubjectExist = errors.New("Subject of the message is already exists")
	ErrNoRecipient  = errors.New("No recipient")
)

Functions

func LoginAuth

func LoginAuth(username, password string) *loginAuth

Types

type Config

type Config struct {
	Key         string     `yaml:"key"`
	Description string     `yaml:"description"`
	SMTP        ServerInfo `yaml:"smtp"`
	POP3        ServerInfo `yaml:"pop3"`
	Email       string     `yaml:"email"`
	Username    string     `yaml:"username"`
	Password    string     `yaml:"password"`
}

type Content

type Content struct {
	HTMLType bool   `json:"html_type"`
	Data     []byte `json:"data"`
}

type Email

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

func NewEmail

func NewEmail() *Email

func (*Email) Config

func (e *Email) Config() []*Config

List of all connection config

func (*Email) Init

func (e *Email) Init() error

func (*Email) ReadMessage

func (e *Email) ReadMessage(key string, number int64) (*MessageInfo, error)

func (*Email) Send

func (e *Email) Send(key string, msg *Message) error

Sending email

func (*Email) Stat

func (e *Email) Stat(key string) ([]*Stat, error)

type File

type File struct {
	Name string `json:"name"`
	Data []byte `json:"data"`
}

type Message

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

func NewMessage

func NewMessage() *Message

func (*Message) AddContent

func (m *Message) AddContent(content *Content)

func (*Message) AddRecipient

func (m *Message) AddRecipient(recipient string)

func (*Message) AttachFile

func (m *Message) AttachFile(file *File)

func (*Message) Bytes

func (m *Message) Bytes() ([]byte, error)

func (*Message) FileCount

func (m *Message) FileCount() int

Returns all attached files

func (*Message) IsFile

func (m *Message) IsFile() bool

Checking if any file attached to the message

func (*Message) Recipients

func (m *Message) Recipients() string

func (*Message) Sender

func (m *Message) Sender() string

func (*Message) SenderAddress

func (m *Message) SenderAddress() string

func (*Message) SenderName

func (m *Message) SenderName() string

func (*Message) SetSender

func (m *Message) SetSender(name, address string)

func (*Message) SetSubject

func (m *Message) SetSubject(subject string)

func (*Message) String

func (m *Message) String() (string, error)

func (*Message) Subject

func (m *Message) Subject() string

type MessageInfo

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

func NewMessageInfo

func NewMessageInfo(reader *textproto.Reader) *MessageInfo

func (*MessageInfo) Contents

func (m *MessageInfo) Contents() []*Content

func (*MessageInfo) Date

func (m *MessageInfo) Date() string

func (*MessageInfo) Files

func (m *MessageInfo) Files() []*File

func (*MessageInfo) MessageId

func (m *MessageInfo) MessageId() string

func (*MessageInfo) ParseBody

func (m *MessageInfo) ParseBody() error

func (*MessageInfo) Sender

func (m *MessageInfo) Sender() *mail.Address

func (*MessageInfo) Subject

func (m *MessageInfo) Subject() string

type ReceiveFunc

type ReceiveFunc func(info Stat) error

type SMTPServer

type SMTPServer struct {
}

func (*SMTPServer) CRAMMD5Auth

func (s *SMTPServer) CRAMMD5Auth(config *Config) smtp.Auth

func (*SMTPServer) LoginAuth

func (s *SMTPServer) LoginAuth(config *Config) smtp.Auth

func (*SMTPServer) PlainAuth

func (s *SMTPServer) PlainAuth(config *Config) smtp.Auth

type ServerInfo

type ServerInfo struct {
	Hostname   string `yaml:"hostname"`
	Port       int    `yaml:"port"`
	Encryption bool   `yaml:"encryption"`
}

type Stat

type Stat struct {
	Key           string `json:"key"`
	MessageNumber int64  `json:"message_number"`
	ID            int64  `json:"message_id"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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