Simple E-mail sender for Go Programming Language.
Supports rich e-mails and ,optionally, Unix built'n sendmail
command.
The only requirement is the Go Programming Language.
$ go get -u github.com/kataras/go-mailer
New
returns a new, e-mail sender service.Send
send an e-mail, supports text/html andsendmail
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 [email protected] 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: "[email protected]",
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{"[email protected]", "[email protected]"}
// Send the e-mail
err := mailer.Send(subject, content, to...)
if err != nil {
println("Error while sending the e-mail. Trace: "+err.Error())
}
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 |
Explore these questions or navigate to the community chat.
Current: v0.0.1
The author of go-mailer is @kataras.
If you're willing to donate, feel free to send any amount through paypal
If you are interested in contributing to the go-mailer project, please make a PR.
This project is licensed under the MIT License.
License can be found here.