-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes golang#9776 Change-Id: I53741fd970244bbfa6874adcb4f1e3d0e7de386b Reviewed-on: https://go-review.googlesource.com/4162 Reviewed-by: Andrew Gerrand <[email protected]>
- Loading branch information
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,14 +46,36 @@ func Example() { | |
} | ||
} | ||
|
||
// variables to make ExamplePlainAuth compile, without adding | ||
// unnecessary noise there. | ||
var ( | ||
from = "[email protected]" | ||
msg = []byte("dummy message") | ||
recipients = []string{"[email protected]"} | ||
) | ||
|
||
func ExamplePlainAuth() { | ||
// hostname is used by PlainAuth to validate the TLS certificate. | ||
hostname := "mail.example.com" | ||
auth := smtp.PlainAuth("", "[email protected]", "password", hostname) | ||
|
||
err := smtp.SendMail(hostname+":25", auth, from, recipients, msg) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func ExampleSendMail() { | ||
// Set up authentication information. | ||
auth := smtp.PlainAuth("", "[email protected]", "password", "mail.example.com") | ||
|
||
// Connect to the server, authenticate, set the sender and recipient, | ||
// and send the email all in one step. | ||
to := []string{"[email protected]"} | ||
msg := []byte("This is the email body.") | ||
msg := []byte("To: [email protected]\r\n" + | ||
"Subject: discount Gophers!\r\n" + | ||
"\r\n" + | ||
"This is the email body.\r\n") | ||
err := smtp.SendMail("mail.example.com:25", auth, "[email protected]", to, msg) | ||
if err != nil { | ||
log.Fatal(err) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters