Skip to content

📫 Simple e-mail sender for Go Programming Language

License

Notifications You must be signed in to change notification settings

guoyu07/go-mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status License Releases Read me docs Build Status Built with GoLang Platforms

Simple E-mail sender for Go Programming Language.

Supports rich e-mails and ,optionally, Unix built'n sendmail command.

Installation

The only requirement is the Go Programming Language.

$ go get -u github.com/kataras/go-mailer

Docs

  • New returns a new, e-mail sender service.
  • Send send an e-mail, supports text/html and sendmail unix command
Send(subject string, body string, to ...string) error

Configuration

type Config struct {
    // Host is the server mail host, IP or address
    Host string
    // Port is the listening port
    Port int
    // Username is the auth username@domain.com for the sender
    Username string
    // Password is the auth password for the sender
    Password string
    // FromAlias is the from part, if empty this is the first part before @ from the Username field
    FromAlias string
    // UseCommand enable it if you want to send e-mail with the mail command  instead of smtp
    //
    // Host,Port & Password will be ignored
    // ONLY FOR UNIX
    UseCommand bool
}

Usage

import "github.com/kataras/go-mailer"

//...

// sender configuration
config := mailer.Config{
    Host:     "smtp.mailgun.org",
    Username: "postmaster@sandbox661c307650f04e909150b37c0f3b2f09.mailgun.org",
    Password: "38304272b8ee5c176d5961dc155b2417",
    Port:     587,
    UseCommand:false,
    // Enable UseCommand to support sendmail unix command, if this field is true then Host, Username, Password and Port are not required, because these info already exists in your local sendmail configuration
}

// initalize a new mail sender service
sender := mailer.New(config)

// the subject/title of the e-mail
subject := "Hello subject"

// the rich message body
content := `<h1>Hello</h1> <br/><br/> <span style="color:red"> This is the rich message body </span>`

// the recipient(s)
to := []string{"kataras2006@hotmail.com", "social@ideopod.com"}


// Send the e-mail
err := mailer.Send(subject, content, to...)

if err != nil {
  println("Error while sending the e-mail. Trace: "+err.Error())
}

go-* packages

Name Description
go-errors Error handling
go-fs FileSystem utils and common net/http static files handlers
go-events EventEmmiter for Go
go-installer Download & Install remote zipped files
go-websocket A websocket server and ,optionally, client side lib for Go
go-ssh SSH Server, build ssh interfaces, remote commands and remote cli with ease
go-gzipwriter Write gzip data to a io.Writer
rizla Monitor and live-reload of your Go App
Q HTTP2 Web Framework, 100% compatible with net/http
Iris The fastest web framework. Built on top of fasthttp

FAQ

Explore these questions or navigate to the community chat.

Versioning

Current: v0.0.1

People

The author of go-mailer is @kataras.

If you're willing to donate, feel free to send any amount through paypal

Contributing

If you are interested in contributing to the go-mailer project, please make a PR.

License

This project is licensed under the MIT License.

License can be found here.

About

📫 Simple e-mail sender for Go Programming Language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages