Add fieldName when constructing SmtpMessage + go fmt
This commit is contained in:
parent
63963b6b19
commit
0f9c32161c
3 changed files with 20 additions and 20 deletions
|
@ -12,11 +12,11 @@ package mailer
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"github.com/mailgun/mailgun-go"
|
||||
"github.com/writefreely/writefreely/config"
|
||||
"github.com/writeas/web-core/log"
|
||||
"github.com/writefreely/writefreely/config"
|
||||
mail "github.com/xhit/go-simple-mail/v2"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -79,13 +79,13 @@ func (m *Mailer) NewMessage(from, subject, text string, to ...string) (*Message,
|
|||
if m.mailGun != nil {
|
||||
msg.mgMsg = m.mailGun.NewMessage(from, subject, text, to...)
|
||||
} else if m.smtp != nil {
|
||||
msg.smtpMsg = &SmtpMessage {
|
||||
from,
|
||||
"",
|
||||
subject,
|
||||
make([]Recipient, len(to)),
|
||||
"",
|
||||
text,
|
||||
msg.smtpMsg = &SmtpMessage{
|
||||
from: from,
|
||||
replyTo: "",
|
||||
subject: subject,
|
||||
recipients: make([]Recipient, len(to)),
|
||||
html: "",
|
||||
text: text,
|
||||
}
|
||||
for _, r := range to {
|
||||
msg.smtpMsg.recipients = append(msg.smtpMsg.recipients, Recipient{r, make(map[string]string)})
|
||||
|
@ -104,7 +104,7 @@ func (m *Message) SetHTML(html string) {
|
|||
}
|
||||
|
||||
func (m *Message) SetReplyTo(replyTo string) {
|
||||
if (m.smtpMsg != nil) {
|
||||
if m.smtpMsg != nil {
|
||||
m.smtpMsg.replyTo = replyTo
|
||||
} else {
|
||||
m.mgMsg.SetReplyTo(replyTo)
|
||||
|
@ -142,7 +142,7 @@ func (m *Mailer) Send(msg *Message) error {
|
|||
for _, r := range msg.smtpMsg.recipients {
|
||||
customMsg := mail.NewMSG()
|
||||
customMsg.SetFrom(msg.smtpMsg.from)
|
||||
if (msg.smtpMsg.replyTo != "") {
|
||||
if msg.smtpMsg.replyTo != "" {
|
||||
customMsg.SetReplyTo(msg.smtpMsg.replyTo)
|
||||
}
|
||||
customMsg.SetSubject(msg.smtpMsg.subject)
|
||||
|
|
|
@ -14,8 +14,8 @@ import (
|
|||
"errors"
|
||||
"html/template"
|
||||
"io"
|
||||
"os"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue