Skip to content

3927o/mail-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-Mail-Helper

a helper for go to send/receive mail by protocol

Usage

send mail

func TestSendMessageSimple(t *testing.T) {
	account := "xxxxx@qq.com"
	pwd := "xxxxx"

	if err := SendMessageSimple(account, pwd, account, "test", "testaaaaaaa"); err != nil {
		t.Error("send message fail: " + err.Error())
	}
}

func TestSendMail(t *testing.T) {
	account := "xxxxx@qq.com"
	pwd := "xxxxx"

	provider, _ := provider.GetMailProviderByAddr(account)
	cli, _ := ConnectSimple(provider)
s
	auth := NewLoginAuth(account, pwd)
	err := cli.Auth(auth)
	if err != nil {
		t.Error("auth fail: " + err.Error())
	}

	if err := SendMessage(cli, message.Message{From: account, To: []string{account}, Subject: "test", Content: []byte("testaaaaaaa")}); err != nil {
		t.Error("send message fail: " + err.Error())
	}
}

receive mail

func TestReceiveMailSimple(t *testing.T) {
	account := "xxxxx@qq.com"
	pwd := "xxxxx"

	if messages, err := ReceiveMailSimple(account, pwd); err != nil {
		t.Error("receive mail fail: " + err.Error())
	} else {
		fmt.Println(messages)
	}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages