package
module
Version:
v0.0.0-...-ba1a32f
Opens a new window with list of versions in this module.
Published: Dec 22, 2017
License: MIT
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
go-email
Send Email with your custom template with Golang, easy and straight forward
Install
$ go get github.com/wuriyanto48/goemail
Result
Usage
-
Example Html Email Template or using this awesome template https://github.com/leemunroe/responsive-html-email-template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
</head>
<body>
<p>
Hi {{.Username}}
<h4>Your Account Registration Success</h4>
<p>Please follow link bellow, to complete your Registration</p>
<a href="{{.URL}}">Confirm email address</a>
</p>
</body>
</html>
-
Golang Code
package main
import (
"fmt"
"github.com/wuriyanto48/goemail"
)
func main() {
authEmail := "wuriyanto007@gmail.com"
authPassword := "your email password"
authHost := "smtp.gmail.com"
address := "smtp.gmail.com:587"
to := []string{"wuriyanto48@yahoo.co.id"}
from := "wuriyanto007@gmail.com"
subject := "Golang email"
body := "Golang email sent..."
email := goemail.New(to, address, from, subject, body, authEmail, authPassword, authHost)
emailData := struct {
Username string
URL string
}{
Username: "Wuriyanto",
URL: "wuriyanto.com",
}
err := goemail.Execute(email, "template.html", emailData)
if err != nil {
fmt.Println(err)
}
fmt.Println("email sent")
}
Authors
Documentation
¶
func Execute(u emailSender, fileName string, data interface{}) error
Execute function for execute EmailSender implementation
func New(to []string, address, from, subject, body, authEmail, authPassword, authHost string) emailSender
New function, for initialize email model
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.