email

package module
v0.0.0-...-08290b3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

README

email

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginAuth

func LoginAuth(username, password string) smtp.Auth

LoginAuth returns loginAuth, and implements smtp.Auth interface.

func SendMail

func SendMail(host, port, username, password, tos, subject, body string) error

SendMail simple send email

Types

type Attachment

type Attachment struct {
	Name   string `json:"name" yaml:"name"`
	Data   []byte `json:"-" yaml:"-"`
	Inline bool   `json:"inline" yaml:"inline"`
}

Attachment represents an email attachment.

func NewAttachment

func NewAttachment(name string, inline bool) (*Attachment, error)

NewAttachment create new attach

type Config

type Config struct {
	Host     string `json:"host" yaml:"host"`
	Port     string `json:"port" yaml:"port"`
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
	Timeout  int    `json:"timeout" yaml:"timeout"`
}

Config config

func (*Config) Parse

func (c *Config) Parse(v interface{}) error

Parse smtp from v

type Message

type Message struct {
	mail.Header
	Body        string
	Attachments []*Attachment
}

Message email message

func NewMessage

func NewMessage() *Message

NewMessage new message

func (*Message) Attachment

func (msg *Message) Attachment(attach *Attachment) *Message

Attachment Attachment

func (*Message) Bcc

func (msg *Message) Bcc(value ...string) *Message

Bcc set bcc

func (*Message) Cc

func (msg *Message) Cc(value ...string) *Message

Cc set cc

func (*Message) From

func (msg *Message) From(value ...string) *Message

From set sender

func (*Message) HTML

func (msg *Message) HTML(body string) *Message

HTML html

func (*Message) Now

func (msg *Message) Now() *Message

Now set time now

func (*Message) ReplyTo

func (msg *Message) ReplyTo(values ...string) *Message

ReplyTo reply to

func (*Message) SetHeader

func (msg *Message) SetHeader(key string, value ...string) *Message

SetHeader set header

func (*Message) Subject

func (msg *Message) Subject(value ...string) *Message

Subject set subject

func (*Message) Text

func (msg *Message) Text(body string) *Message

Text text

func (*Message) To

func (msg *Message) To(value ...string) *Message

To set receivers

func (*Message) UnmarshalJSON

func (msg *Message) UnmarshalJSON(data []byte) error

UnmarshalJSON UnmarshalJSON

func (*Message) Version

func (msg *Message) Version() *Message

Version set default version

type SMTP

type SMTP struct {
	*Config
	// contains filtered or unexported fields
}

SMTP client

func New

func New(config *Config) (*SMTP, error)

New smtp client

func NewSMTP

func NewSMTP(host, port, username, password string) (*SMTP, error)

NewSMTP with every config item

func (*SMTP) Auth

func (s *SMTP) Auth() error

Auth auth

func (*SMTP) Close

func (s *SMTP) Close() error

Close connection

func (*SMTP) Noop

func (s *SMTP) Noop() error

Noop send noop cmd

func (*SMTP) Send

func (s *SMTP) Send(msg *Message) error

Send message

func (*SMTP) SendExt

func (s *SMTP) SendExt(msg *Message) error

SendExt is used some special scenario, must require MAIL command before RCPT command.

func (*SMTP) Write

func (s *SMTP) Write(b []byte) (int, error)

Write write

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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