mailq-inspector/mailq/queue.go

35 lines
554 B
Go

package mailq
import (
"errors"
"fmt"
"time"
)
type MailQ struct {
NumTotal int
NumActive int
NumHold int
NumDeferred int
Entries []QEntry
}
type QEntry struct {
Id string
Status string
Date time.Time
Size int
Sender string
Recipients []string
Reason string
}
func (q MailQ) GetMessageById(id string) (QEntry, error) {
for _, entry := range q.Entries {
if entry.Id == id {
return entry, nil
}
}
return QEntry{}, errors.New(fmt.Sprintf("No message with id '%s' available!", id))
}