Skip to content

oinpentuls/mail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
}

About

Package that help sending email

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages