diff --git a/example_test.go b/example_test.go index 3cafcf2..a4bd1d8 100644 --- a/example_test.go +++ b/example_test.go @@ -5,6 +5,7 @@ import ( "html/template" "io" "log" + "net/smtp" "time" "gopkg.in/gomail.v2" @@ -113,6 +114,24 @@ func Example_noAuth() { } } +// Send an email using the CRAM-MD5 authentication mechanism. +func Example_CRAM_MD5() { + m := gomail.NewMessage() + m.SetHeader("From", "from@example.com") + m.SetHeader("To", "to@example.com") + m.SetHeader("Subject", "Hello!") + m.SetBody("text/plain", "Hello!") + + d := gomail.Dialer{ + Host: "localhost", + Port: 587, + Auth: smtp.CRAMMD5Auth("username", "secret"), + } + if err := d.DialAndSend(m); err != nil { + panic(err) + } +} + // Send an email using an API or postfix. func Example_noSMTP() { m := gomail.NewMessage()