pmail

package
v0.0.0-...-9a1677b Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2020 License: MIT Imports: 3 Imported by: 0

README

pmail使用示例:

    // smtp = "smtp@xxx.com"
	pmail.InitMailConfig("smtp@xxx.com", "username", "passwd", "fromname <from@xxx.com>", "port")
	pm := pmail.NewPmail()
	pm.AddCcUsers(map[string]string{"xxxx@abc.cn": "cc人员"})   //[可选] 抄送人员
	address := []string{"address@xxx.cn"}                                         //实际发送地址
	body := "<span style='color:green;font-size:12px;'>Hello this is test</span>" //支持html
	title := "测试Pmail邮件"                                                          //标题
    pm.AddAttachment("/tmp/test_mail.txt"); //[可选] 增加附件
	err := pm.SendMail(address, title, body)     //内部实现支持HTML
	if err != nil {
		panic(err)
	}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMailConfig

func InitMailConfig(smtp, user, pass, from string, port int)

Types

type Pmail

type Pmail struct {
	M *gomail.Message
	D *gomail.Dialer
}

func NewPmail

func NewPmail() *Pmail

func (*Pmail) AddAttachment

func (p *Pmail) AddAttachment(filepath string) error

[可选] 添加附件

func (*Pmail) AddCcUsers

func (p *Pmail) AddCcUsers(ccUsers map[string]string)

[可选] 添加抄送人员

func (*Pmail) SendMail

func (p *Pmail) SendMail(address []string, title, body string) error

发送邮件

Jump to

Keyboard shortcuts

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