|
|
@ -10,6 +10,7 @@ import (
|
|
|
|
"html/template"
|
|
|
|
"html/template"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"io/fs"
|
|
|
|
"io/fs"
|
|
|
|
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
"net/url"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
@ -99,7 +100,7 @@ func NewEmailer(app *appContext) *Emailer {
|
|
|
|
app.err.Printf(lm.FailedInitSMTP, err)
|
|
|
|
app.err.Printf(lm.FailedInitSMTP, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if method == "mailgun" {
|
|
|
|
} else if method == "mailgun" {
|
|
|
|
emailer.NewMailgun(app.config.Section("mailgun").Key("api_url").String(), app.config.Section("mailgun").Key("api_key").String())
|
|
|
|
emailer.NewMailgun(app.config.Section("mailgun").Key("api_url").String(), app.config.Section("mailgun").Key("api_key").String(), app.proxyTransport)
|
|
|
|
} else if method == "dummy" {
|
|
|
|
} else if method == "dummy" {
|
|
|
|
emailer.sender = &DummyClient{}
|
|
|
|
emailer.sender = &DummyClient{}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -201,10 +202,14 @@ type Mailgun struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewMailgun returns a Mailgun emailClient.
|
|
|
|
// NewMailgun returns a Mailgun emailClient.
|
|
|
|
func (emailer *Emailer) NewMailgun(url, key string) {
|
|
|
|
func (emailer *Emailer) NewMailgun(url, key string, transport *http.Transport) {
|
|
|
|
sender := &Mailgun{
|
|
|
|
sender := &Mailgun{
|
|
|
|
client: mailgun.NewMailgun(strings.Split(emailer.fromAddr, "@")[1], key),
|
|
|
|
client: mailgun.NewMailgun(strings.Split(emailer.fromAddr, "@")[1], key),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if transport != nil {
|
|
|
|
|
|
|
|
cli := sender.client.Client()
|
|
|
|
|
|
|
|
cli.Transport = transport
|
|
|
|
|
|
|
|
}
|
|
|
|
// Mailgun client takes the base url, so we need to trim off the end (e.g 'v3/messages')
|
|
|
|
// Mailgun client takes the base url, so we need to trim off the end (e.g 'v3/messages')
|
|
|
|
if strings.Contains(url, "messages") {
|
|
|
|
if strings.Contains(url, "messages") {
|
|
|
|
url = url[0:strings.LastIndex(url, "/")]
|
|
|
|
url = url[0:strings.LastIndex(url, "/")]
|
|
|
|