| 1234567891011121314151617181920212223242526272829 |
- // smtp_auth.go
- package main
- import (
- "log"
- "net/smtp"
- )
- func main() {
- // 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.
- err := smtp.SendMail(
- "mail.example.com:25",
- auth,
- "[email protected]",
- []string{"[email protected]"},
- []byte("This is the email body."),
- )
- if err != nil {
- log.Fatal(err)
- }
- }
|