Get as far as storing an incoming mail in crockery.db
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/mail"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/emersion/go-smtp"
|
||||
@@ -74,6 +75,30 @@ func (m *mta) AnonymousLogin() (smtp.User, error) {
|
||||
// User implementation for go-smtp after this point
|
||||
// Since only anonymous login is permitted, there's no need to introduce an
|
||||
// intermediary to track the logged-in user.
|
||||
//
|
||||
// TODO: wildcard address support. For now, just dump everything directly
|
||||
// into a single hardcoded mailbox per-account
|
||||
func (m *mta) ServeSMTP(from string, to []string, r io.Reader) error {
|
||||
return fmt.Errorf("Not yet implemented")
|
||||
emails := make([]string, len(to))
|
||||
|
||||
for i, entry := range to {
|
||||
addr, err := mail.ParseAddress(entry) // FIXME: should this be AddressList?
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
emails[i] = addr.Address
|
||||
}
|
||||
|
||||
log.Printf("emails: %#v", emails)
|
||||
|
||||
recipients, err := m.store.FindAccounts(emails...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(recipients) != len(to) {
|
||||
return fmt.Errorf("At least one recipient is not known locally")
|
||||
}
|
||||
|
||||
return m.store.SpoolMessage(recipients, r)
|
||||
}
|
||||
|
Reference in New Issue
Block a user