Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 742 Bytes

README.md

File metadata and controls

43 lines (33 loc) · 742 Bytes

Mail Go

This package is created for supporting my work, I would be glad if the package can help you too.

Installation

go get github.com/oinpentuls/mail-go

Usage

Config the smtp server

options := mail.MailOptions{
    Host:     "host",
    Port:     "port",
    Username: "username",
    Password: "password",
}

construct new mail

mail := mail.New(options)
mail.SetFrom("[email protected]")
mail.SetTo([]string{"[email protected]"})
mail.SetSubject("Hello")

mail.SetBodyPlainText([]byte("Hello World"))

mail.SetBodyHTML([]byte("<h1>Hello World</h1>"))

err := mail.SetAttachment(filepath.Join("my_file.pdf"))
if err != nil {
    log.Fatal(err)
}

err = mail.Send()
if err != nil {
    log.Fatal(err)
}