Skip to content

Instantly share code, notes, and snippets.

@jpillora
Last active July 19, 2025 18:39
Show Gist options
  • Select an option

  • Save jpillora/cb46d183eca0710d909a to your computer and use it in GitHub Desktop.

Select an option

Save jpillora/cb46d183eca0710d909a to your computer and use it in GitHub Desktop.

Revisions

  1. jpillora revised this gist Mar 28, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions smtp-gmail-send.go
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,7 @@ func send(body string) {

    if err != nil {
    log.Printf("smtp error: %s", err)
    return
    }

    log.Print("sent, visit http://foobarbazz.mailinator.com")
  2. jpillora created this gist Mar 28, 2015.
    31 changes: 31 additions & 0 deletions smtp-gmail-send.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    package main

    import (
    "log"
    "net/smtp"
    )

    func main() {
    send("hello there")
    }

    func send(body string) {
    from := "[email protected]"
    pass := "..."
    to := "[email protected]"

    msg := "From: " + from + "\n" +
    "To: " + to + "\n" +
    "Subject: Hello there\n\n" +
    body

    err := smtp.SendMail("smtp.gmail.com:587",
    smtp.PlainAuth("", from, pass, "smtp.gmail.com"),
    from, []string{to}, []byte(msg))

    if err != nil {
    log.Printf("smtp error: %s", err)
    }

    log.Print("sent, visit http://foobarbazz.mailinator.com")
    }