goweb_mail

package module
v0.0.0-...-0008ca0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: MIT Imports: 8 Imported by: 0

README

goweb-mail

建立一个邮局,用于邮件发送

useage:

func main() {
	// PostOffice Config
	server := ""
	port := ""
	username := ""
	password := ""

	// Message info
	from := ""
	subject := ""
	body := ""
	to := ""
	PostOffice := NewPostOffice(server, port, username, password)
	message := Message{
		From:    from,
		Subject: subject,
		Body:    body,
	}
	usPostman := HirePostman(message, PostOffice)
	usPostman.SendMail(to)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MailClient

type MailClient struct {
	Account    string
	Password   string
	StartTime  string //开通时间,申请邮箱6个月密码过期
	MailServer string
	Port       int
	Debug      bool
	Admins     []string
	// contains filtered or unexported fields
}

func NewMailClient

func NewMailClient(account, password, mailServer, startTime string, port int, debug bool, admins []string) (*MailClient, error)

func (*MailClient) SendEmailToAdmin

func (mc *MailClient) SendEmailToAdmin(content string, subject ...string) error

func (*MailClient) SendEmailToUser

func (mc *MailClient) SendEmailToUser(users []string, subject string, content string, contentType ...string) error

type Message

type Message struct {
	From    string
	To      string
	Subject string
	Body    string
}

Message 消息模板

func (*Message) Byte

func (m *Message) Byte() []byte

Byte将Message 转换为可直接发送的字节数组

type PostOffice

type PostOffice interface {
	ReciveMail(Message)
}

func NewPostOffice

func NewPostOffice(server, port, username, password string) PostOffice

NewPostOffice 建立一个邮局

type Postman

type Postman interface {
	SendMail(string)
}

Postman 邮差的工作内容

func HirePostman

func HirePostman(message Message, PostOffice PostOffice) Postman

HirePostman 招聘一名专职邮差负责向 PostOffice 投递 Message

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳