Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.


Build Status GoDoc

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 "" and "First Last <>" format
  • Text and HTML Message Body
  • Attachments
  • Read Receipts
  • Custom headers
  • More to come!


go get

Note: Version > 1 of this library requires Go v1.5 or above.

If you need compatibility with previous Go versions, you can use the previous package at


Sending email using Gmail

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

Another Method for Creating an Email

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

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

Creating an Email From an io.Reader

You can also create an email from any type that implements the io.Reader interface by using email.NewEmailFromReader.

Attaching a File

e := NewEmail()

A Pool of Reusable Connections

(var ch <-chan *email.Email)
p := email.NewPool(
	smtp.PlainAuth("", "", "password123", ""),
for i := 0; i < 4; i++ {
	go func() {
		for e := range ch {
			p.Send(e, 10 * time.Second)


Other Sources

Sections inspired by the handy gophermail project.


I'd like to thank all the contributors and maintainers of this package.

A special thanks goes out to Jed Denlea jeddenlea for his numerous contributions and optimizations.