Skip to content

rayleyva/email

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

email

Build Status

Robust and flexible email library for Go

Email for humans

The email package is designed to be simple to use, but flexible enough so as not to be restrictive. The goal is to provide an email interface for humans.

The email package currently supports the following:

  • From, To, Bcc, and Cc fields
  • Email addresses in both "test@example.com" and "First Last <test@example.com>" format
  • Text and HTML Message Body
  • Attachments
  • Read Receipts
  • Custom headers
  • More to come!

Installation

go get github.com/jordan-wright/email

Note: Requires go version 1.1 and above

Examples

Sending email using Gmail

e := email.NewEmail()
e.From = "Jordan Wright <test@gmail.com>"
e.To = []string{"test@example.com"}
e.Bcc = []string{"test_bcc@example.com"}
e.Cc = []string{"test_cc@example.com"}
e.Subject = "Awesome Subject"
e.Text = "Text Body is, of course, supported!"
e.HTML = "<h1>Fancy HTML is supported, too!</h1>"
e.Send("smtp.gmail.com:587", smtp.PlainAuth("", "test@gmail.com", "password123", "smtp.gmail.com"))

Another Method for Creating an Email

You can also create an email directly by creating a struct as follows:

e := &email.Email {
	To: []string{"test@example.com"},
	From: "Jordan Wright <test@gmail.com>",
	Subject: "Awesome Subject",
	Text: "Text Body is, of course, supported!",
	HTML: "<h1>Fancy HTML is supported, too!</h1>",
	Headers: textproto.MIMEHeader{},
}

Attaching a File

e := NewEmail()
e.AttachFile("test.txt")

Documentation

http://godoc.org/github.com/jordan-wright/email

Other Sources

Sections inspired by the handy gophermail project.

About

Robust and flexible email library for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published