mail

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginAuth

func LoginAuth(username, password string) smtp.Auth

LoginAuth loginAuth方式认证

func MailAddr

func MailAddr(name string, address string) *mail.Address

func SendMail

func SendMail(subject string, content string, receiver, sender string,
	bcc []string, smtpConfig *SMTPConfig, attachments *Attachments) error

SendMail 发送电邮

Types

type Attachments

type Attachments struct {
	Files   []string
	BaseDir string
}

type Mail

type Mail struct {
	To         []string
	ToName     []string
	Subject    string
	HTML       string
	Text       string
	From       string
	Bcc        []string
	FromName   string
	ReplyTo    string
	Date       string
	Files      map[string]string
	Headers    string
	BaseDir    string //内容中图片路径
	Charset    string //编码
	RetReceipt string //回执地址,空白则禁用回执
}

Mail will represent a formatted email

func NewMail

func NewMail() Mail

NewMail returns a new Mail

func (*Mail) AddAttachment

func (m *Mail) AddAttachment(filePath string) error

AddAttachment will include file/s in mail

func (*Mail) AddBCC

func (m *Mail) AddBCC(email string) error

AddBCC works like AddTo but for BCC

func (*Mail) AddDate

func (m *Mail) AddDate(date string)

AddDate specifies the date

func (*Mail) AddFrom

func (m *Mail) AddFrom(from string) error

AddFrom will set the senders email

func (*Mail) AddFromName

func (m *Mail) AddFromName(name string)

AddFromName will set the senders name

func (*Mail) AddHTML

func (m *Mail) AddHTML(html string)

AddHTML will set the body of the mail

func (*Mail) AddHeaders

func (m *Mail) AddHeaders(headers string)

AddHeaders addding header string

func (*Mail) AddRecipient

func (m *Mail) AddRecipient(receipient *mail.Address)

AddRecipient will take an already parsed mail.Address

func (*Mail) AddRecipientBCC

func (m *Mail) AddRecipientBCC(email *mail.Address)

AddRecipientBCC works like AddRecipient but for BCC

func (*Mail) AddReplyTo

func (m *Mail) AddReplyTo(reply string)

AddReplyTo will set the return address

func (*Mail) AddSubject

func (m *Mail) AddSubject(s string)

AddSubject will set the subject of the mail

func (*Mail) AddText

func (m *Mail) AddText(text string)

AddText will set the body of the email

func (*Mail) AddTo

func (m *Mail) AddTo(email string) error

AddTo will take a valid email address and store it in the mail. It will return an error if the email is invalid.

func (*Mail) AddToName

func (m *Mail) AddToName(name string)

AddToName will add a new receipient name to mail

func (*Mail) ReadAttachment

func (m *Mail) ReadAttachment(filePath string) (string, error)

ReadAttachment reading attachment

func (*Mail) SetTos

func (m *Mail) SetTos(emails []string)

SetTos 设置收信人Email地址

type SMTPClient

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

SMTPClient struct

func NewSMTPClient

func NewSMTPClient(conf *SMTPConfig) SMTPClient

func (*SMTPClient) NewMail

func (c *SMTPClient) NewMail() Mail

NewMail returns a new Mail

func (*SMTPClient) Send

func (c *SMTPClient) Send(m Mail) error

Send - It can be used for generic SMTP stuff

func (*SMTPClient) SendTLS

func (c *SMTPClient) SendTLS(m Mail, message bytes.Buffer) error

SendTLS 通过TLS发送

type SMTPConfig

type SMTPConfig struct {
	Username string
	Password string
	Host     string
	Port     int
	Secure   string
	Identity string
}

SMTPConfig 配置结构体

func (*SMTPConfig) Address

func (s *SMTPConfig) Address() string

func (*SMTPConfig) Auth

func (s *SMTPConfig) Auth() smtp.Auth

Jump to

Keyboard shortcuts

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