Browse Source

Sort displayed values

pull/1/head
Jan-Lukas Else 4 years ago
parent
commit
80b557f884
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      mail.go

+ 9
- 2
mail.go View File

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"net/smtp" "net/smtp"
"sort"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -29,10 +30,16 @@ func buildMessage(recipient string, date time.Time, values FormValues) string {
_, _ = fmt.Fprintf(&msgBuffer, "Subject: New submission on %s", findFormName(values)) _, _ = fmt.Fprintf(&msgBuffer, "Subject: New submission on %s", findFormName(values))
_, _ = fmt.Fprintln(&msgBuffer) _, _ = fmt.Fprintln(&msgBuffer)
_, _ = fmt.Fprintln(&msgBuffer) _, _ = fmt.Fprintln(&msgBuffer)
for key, value := range removeMetaValues(values) {
bodyValues := removeMetaValues(values)
var keys []string
for key, _ := range bodyValues {
keys = append(keys, key)
}
sort.Strings(keys)
for _, key := range keys {
_, _ = fmt.Fprint(&msgBuffer, key) _, _ = fmt.Fprint(&msgBuffer, key)
_, _ = fmt.Fprint(&msgBuffer, ": ") _, _ = fmt.Fprint(&msgBuffer, ": ")
_, _ = fmt.Fprintln(&msgBuffer, strings.Join(value, ", "))
_, _ = fmt.Fprintln(&msgBuffer, strings.Join(bodyValues[key], ", "))
} }
return msgBuffer.String() return msgBuffer.String()
} }


Loading…
Cancel
Save