Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsyncSend ¶
AsyncSend is func to async send mail
Example ¶
package main import ( "bytes" "fmt" "sync" "github.com/Cluas/gim/pkg/mail" ) func main() { var wg sync.WaitGroup wg.Add(1) err := mail.AsyncSend(&mail.Message{ Subject: "测试", Content: bytes.NewBufferString("<h1>你好,异步发送测试邮件内容</h1>"), To: []string{"huwl@luedongtech.com"}, //Extension: nil, }, func(err error) { defer wg.Done() if err != nil { fmt.Println("发送邮件出现错误:", err) } }) if err != nil { fmt.Printf("发送错误, %v", err) } wg.Wait() }
Output:
func Send ¶
Send is func to send mail
Example ¶
package main import ( "bytes" "fmt" "github.com/Cluas/gim/pkg/mail" ) func main() { err := mail.Send(&mail.Message{ Subject: "测试", Content: bytes.NewBufferString("<h1>你好,同步测试邮件内容</h1>"), To: []string{"huwl@luedongtech.com"}, //Extension: nil, }) if err != nil { fmt.Printf("发送错误, %v", err) } }
Output:
Types ¶
type Message ¶
type Message struct { Subject string Content io.Reader // support html content To []string // to address string Extension map[string]string // message extension }
Message is struct used to send msg
type SMTPSender ¶
type SMTPSender struct {
// contains filtered or unexported fields
}
SMTPSender used to send mail with smtp protocol
Click to show internal directories.
Click to hide internal directories.