Documentation
¶
Overview ¶
Package mail provides an easy interface with interchangable backends
Create and ping Mandrill client
client := mandrill.MustNew("https://mandrillapp.com/api/1.0/", "my-token")
err := client.Ping()
if err != nil {
panic(err)
}
Send email
err = client.Send(&mail.Mail{
From: &mail.Sender{Name: "FastBill GmbH", Email: "no-reply@fastbill.com"},
To: []mail.Recipient{mail.Recipient{Name: "Info", Email: "info@fastbill.com"}},
Subject: "Hello world",
HTML: "<h1>Hello</h1>",
Text: "Hello",
Options: &mandrill.Options{
Important: true,
},
})
if err != nil {
panic(err)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// Send sends an email through the client
Send(*Mail) error
// Ping the address and validate key
Ping() error
}
Client can be implemented for various services
type HTTPClient ¶
type HTTPClient interface {
// Post issues a POST to the specified URL
Post(url string, contentType string, payload io.Reader) (*http.Response, error)
}
HTTPClient is an interface for just the Post-method of *http.Client for easy mocking
type Mail ¶
type Mail struct {
// From is the name and email where this email is sent from
From *Sender
// To holds one or more recipients
To []Recipient
// Subject holds the mail subject
Subject string
// Headers are standard mail headers
Headers map[string]interface{}
// HTML will be displayed as html in the email
HTML string
// Text will be displayed as plain text in the email
Text string
// Options can be a custom interface provided by the client implementation
Options interface{}
}
Mail is a mail you can send
Click to show internal directories.
Click to hide internal directories.