-
-
Save m00zi/cd0b18f8bd8d6802c0e212fd8874e053 to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"bytes" | |
"log" | |
"net/smtp" | |
) | |
func main() { | |
// Connect to the remote SMTP server. | |
c, err := smtp.Dial("smtp.gmail.com:465") | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer c.Close() | |
// Set the sender and recipient. | |
c.Mail("[email protected]") | |
c.Rcpt("[email protected]") | |
// Send the email body. | |
wc, err := c.Data() | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer wc.Close() | |
buf := bytes.NewBufferString("This is the email body.") | |
if _, err = buf.WriteTo(wc); err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment