Browse Source

Remove unused "User" member of Message Struct and fix bounce address

The User member of a message is not needed anymore.

The from that is send to the server, should always be the "system" from. This is also called the Bounce address http://en.wikipedia.org/wiki/Bounce_address
pull/766/head
Peter 10 years ago
parent
commit
edbe1de026
  1. 4
      modules/mailer/mail.go
  2. 9
      modules/mailer/mailer.go

4
modules/mailer/mail.go

@ -30,9 +30,7 @@ const (
// Create New mail message use MailFrom and MailUser // Create New mail message use MailFrom and MailUser
func NewMailMessageFrom(To []string, from, subject, body string) Message { func NewMailMessageFrom(To []string, from, subject, body string) Message {
msg := NewHtmlMessage(To, from, subject, body) return NewHtmlMessage(To, from, subject, body)
msg.User = setting.MailService.User
return msg
} }
// Create New mail message use MailFrom and MailUser // Create New mail message use MailFrom and MailUser

9
modules/mailer/mailer.go

@ -20,7 +20,6 @@ type Message struct {
From string From string
Subject string Subject string
Body string Body string
User string
Type string Type string
Massive bool Massive bool
Info string Info string
@ -66,7 +65,7 @@ func processMailQueue() {
} }
// sendMail allows mail with self-signed certificates. // sendMail allows mail with self-signed certificates.
func sendMail(settings *setting.Mailer, from string, recipients []string, msgContent []byte) error { func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte) error {
host, port, err := net.SplitHostPort(settings.Host) host, port, err := net.SplitHostPort(settings.Host)
if err != nil { if err != nil {
return err return err
@ -125,7 +124,7 @@ func sendMail(settings *setting.Mailer, from string, recipients []string, msgCon
} }
} }
if err = client.Mail(from); err != nil { if err = client.Mail(settings.From); err != nil {
return err return err
} }
@ -168,7 +167,7 @@ func Send(msg *Message) (int, error) {
num := 0 num := 0
for _, to := range msg.To { for _, to := range msg.To {
body := []byte("To: " + to + "\r\n" + content) body := []byte("To: " + to + "\r\n" + content)
err := sendMail(setting.MailService, msg.From, []string{to}, body) err := sendMail(setting.MailService, []string{to}, body)
if err != nil { if err != nil {
return num, err return num, err
} }
@ -179,7 +178,7 @@ func Send(msg *Message) (int, error) {
body := []byte("To: " + strings.Join(msg.To, ";") + "\r\n" + content) body := []byte("To: " + strings.Join(msg.To, ";") + "\r\n" + content)
// send to multiple emails in one message // send to multiple emails in one message
err := sendMail(setting.MailService, msg.From, msg.To, body) err := sendMail(setting.MailService, msg.To, body)
if err != nil { if err != nil {
return 0, err return 0, err
} else { } else {

Loading…
Cancel
Save