diff --git a/maildir.go b/maildir.go index d102549..5785d38 100644 --- a/maildir.go +++ b/maildir.go @@ -7,7 +7,7 @@ import ( "os" "path/filepath" "strings" - + "sort" "github.com/mailhog/data" ) @@ -138,6 +138,11 @@ func (maildir *Maildir) List(start, limit int) (*data.Messages, error) { if err != nil { return nil, err } + sort.Slice(n, func(i, j int) bool { + return n[i].ModTime().After(n[j].ModTime()) + }) + + for _, fileinfo := range n { b, err := ioutil.ReadFile(filepath.Join(maildir.Path, fileinfo.Name()))