Skip to content
/ email Public
forked from scorredoira/email

An easy way to send emails with attachments in Go

License

Notifications You must be signed in to change notification settings

Sata51/email

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

email

An easy way to send emails with attachments in Go

Install

go get github.com/Sata51/email

Usage

package email_test

import (
	"log"
	"net/mail"
	"net/smtp"

	"github.com/Sata51/email"
)

func Example() {
	// compose the message
	m := email.NewMessage("Hi", "this is the body")
	m.From = mail.Address{Name: "From", Address: "from@example.com"}
	m.To = []string{"to@example.com"}

	// add attachments
	if err := m.Attach("email.go", "myEmail.go"); err != nil {
		log.Fatal(err)
	}

	// send it
	auth := smtp.PlainAuth("", "from@example.com", "pwd", "smtp.zoho.com")
	if err := email.Send("smtp.zoho.com:587", auth, m); err != nil {
		log.Fatal(err)
	}
}

Html

	// use the html constructor
	m := email.NewHTMLMessage("Hi", "this is the body")

Inline

	// use Inline to display the attachment inline.
	if err := m.Inline("main.go"); err != nil {
		log.Fatal(err)
	}

About

An easy way to send emails with attachments in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%