# Packages
No description provided by the author
# README
Mail __/ email sender written in Go
This simple package supports rich email messages, unix sendmail
command and more.
The mail
package provides an amazing API to work with.
Installation
The only requirement is the Go Programming Language, at least version 1.9.
$ go get -u -v github.com/kataras/mail
Stable release installation by
go get gopkg.in/kataras/mail.v0
Getting Started
New
returns a new, e-mail sender serviceMail#Send
sends a (rich) email messageMail#Subject("...")
returns aBuilder
for the mail message which ends up withSend() error
,SendUNIX() error
SendUNIX
make use of thesendmail
program of *nix OS, noMail
sender is needed
// New returns a new *Mail, which contains the `Send(...) error`
// and `Subject(...) *Builder` functions.
New(c Credentials) *Mail
Example
$ cat send-mail.go
package main
import "github.com/kataras/mail"
func main() {
c := mail.Credentials{
Addr: "smtp.sendgrid.net:587",
Username: "apikey",
Password: "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",
}
message, err := mail.New(c)
if err != nil {
panic(err)
}
message.
Subject("Subject").
BodyString("Body").
To("[email protected]", "[email protected]").
From("FromName", "[email protected]").
Send()
// Tip #1
//
// Alternative ways to set Body inside a Builder:
// Body([]byte)
// BodyReader(io.Reader)
// BodyReadCloser(io.ReadCloser)
// Tip #2
//
// If you want to re-use a Builder(= `message.Subject(...)`'s result) after the `Send`
// then you have to call the Builder's `MarkSingleton()` before its `Send` execution.
// Small:
//
// [ init time, once after the `mail.New(...)` ]
// message.DefaultFrom = &mail.Address{"FromName", "[email protected]"}
// [[ run time, many ]]
// message.Subject("Subject").BodyString("Body").To("[email protected]").Send()
}
For the stable release use
import gopkg.in/kataras/mail.v0
instead
$ go run send-mail.go
More examples
FAQ
Explore these questions or navigate to the community chat.
Versioning
Current: v0.0.1
Read more about Semantic Versioning 2.0.0
- http://semver.org/
- https://en.wikipedia.org/wiki/Software_versioning
- https://wiki.debian.org/UpstreamGuide#Releases_and_Versions
People
The author of the mail
is @kataras.
Contributing
If you are interested in contributing to the mail
project, please make a PR.
TODO
- Add a simple CLI tool for sending emails
- Read the specification for the email attachment and implement that.
License
This project is licensed under the MIT License. License file can be found here.