PlainAuth returns an Auth that implements the PLAIN authentication mechanism as defined in RFC 4616. The returned Auth uses the given username and password to authenticate on TLS connections to host and act as identity. Usually identity will be left blank to act as username.


	// hostname is used by PlainAuth to validate the TLS certificate.
	hostname := ""
	auth := smtp.PlainAuth("", "[email protected]", "password", hostname)

	err := smtp.SendMail(hostname+":25", auth, from, recipients, msg)

func ExampleSendMail() {
	// Set up authentication information.
	auth := smtp.PlainAuth("", "[email protected]", "password", "")

	// Connect to the server, authenticate, set the sender and recipient,

var authTests = []authTest{
	{PlainAuth("", "user", "pass", "testserver"), []string{}, "PLAIN", []string{"\x00user\x00pass"}},
	{PlainAuth("foo", "bar", "baz", "testserver"), []string{}, "PLAIN", []string{"foo\x00bar\x00baz"}},
	{CRAMMD5Auth("user", "pass"), []string{"<[email protected]>"}, "CRAM-MD5", []string{"", "user 287eb355114cf5c471c26a875f1ca4ae"}},