Standard library / net/smtp
smtp.Auth
Interface for SMTP authentication mechanisms. Start selects the protocol; Next processes challenges or completion. Never log exchanged credential bytes. Expected stdout: 'PLAIN\n'.
Formal Syntax & Structure
go syntaxgo
type Auth interface { Start(server *ServerInfo) (proto string, toServer []byte, err error)
Next(fromServer []byte, more bool) (toServer []byte, err error)}Working Example
Example Snippetgo
package main
import ( "fmt" "net/smtp")
func main() { var a smtp.Auth = smtp.PlainAuth("", "demo", "synthetic", "fixture.invalid") p, _, e := a.Start(&smtp.ServerInfo{Name: "fixture.invalid", TLS: true}) check(e) fmt.Println(p)}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}