goemail

package module
v0.0.0-...-ba1a32f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2017 License: MIT Imports: 3 Imported by: 0

README

go-email

Build Status

Send Email with your custom template with Golang, easy and straight forward

Install

$ go get github.com/wuriyanto48/goemail

Result

alt text

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(u emailSender, fileName string, data interface{}) error

Execute function for execute EmailSender implementation

func New

func New(to []string, address, from, subject, body, authEmail, authPassword, authHost string) emailSender

New function, for initialize email model

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL