https://github.com/fastbill/go-mail
Golang mail library with interchangeable backends
https://github.com/fastbill/go-mail
golang mail mandrill
Last synced: 11 months ago
JSON representation
Golang mail library with interchangeable backends
- Host: GitHub
- URL: https://github.com/fastbill/go-mail
- Owner: fastbill
- License: mit
- Created: 2018-05-01T13:29:53.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-05-23T10:20:10.000Z (about 4 years ago)
- Last Synced: 2024-06-21T01:56:04.882Z (almost 2 years ago)
- Topics: golang, mail, mandrill
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-mail [](https://travis-ci.org/fastbill/go-mail) [](https://godoc.org/github.com/fastbill/go-mail)
Package mail provides an easy interface with interchangable backends.
Pull requests for additional mail providers are very welcome.
## Implementation roadmap
- [x] [Mandrill](https://mandrillapp.com)
## Example usage
```go
package main
import (
"github.com/fastbill/go-mail/v3"
"github.com/fastbill/go-mail/v3/mandrill"
)
func main() {
// Create and ping Mandrill mailer.
mandrillMailer := mandrill.MustNew("https://mandrillapp.com/api/1.0/", "my-token")
err := mandrillMailer.Ping()
if err != nil {
panic(err)
}
// Create template mailer.
templateMailer := MustNewStandardTemplateMailer(mandrillMailer, "/templates/*.tmpl")
// Configure email for sending.
template := &Template{
Data: map[string]interface{}{
"Foo": 1234,
},
TextPath: "hello.text.tmpl",
HTMLPath: "hello.html.tmpl",
}
config := &Config{
From: &Address{Name: "FastBill GmbH", Email: "no-reply@fastbill.com"},
To: []Address{Address{Name: "Info", Email: "info@fastbill.com"}},
Subject: "Hello world",
Options: &mandrill.Options{
Important: true,
},
}
// Send email.
if err := templateMailer.Send(template, config); err != nil {
panic(err)
}
}
```