Created
October 12, 2014 00:10
-
-
Save bradrydzewski/c304e05d4e0e493e8f42 to your computer and use it in GitHub Desktop.
Test Email Configuration
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 ( | |
"net/smtp" | |
) | |
type Email struct { | |
Recipients []string | |
Host string | |
Port string | |
From string | |
Username string | |
Password string | |
} | |
func main() { | |
e := Email{ | |
Recipients: []string{"[email protected]"}, | |
Host: "smtp.foo.com", | |
Port: "587", | |
From: "[email protected]", | |
Username: "foo", | |
Password: "bar", | |
} | |
auth := smtp.PlainAuth("", e.Username, e.Password, e.Host) | |
err := smtp.SendMail(e.Host+":"+e.Port, auth, e.From, e.Recipients, []byte(data)) | |
if err != nil { | |
println(err.Error()) | |
} else { | |
println("Successfully sent email") | |
} | |
} | |
var data = ` | |
From: %s | |
To: %s | |
Subject: TEST EMAIL | |
MIME-Version: 1.0 | |
Content-Type: multipart/alternative; boundary="e255104e821101849e9aefa6986" | |
--e255104e821101849e9aefa6986 | |
Content-Type: text/plain; charset=UTF-8 | |
THIS IS A TEST | |
--e255104e821101849e9aefa6986 | |
Content-Type: text/html; charset=UTF-8 | |
<b>THIS IS A TEST</b> | |
--e255104e821101849e9aefa6986-- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment