parent
3f18d6d1a6
commit
0773d147cc
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue