diff --git a/cmd/recv/main.go b/cmd/recv/main.go index c767653..f67844b 100755 --- a/cmd/recv/main.go +++ b/cmd/recv/main.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "io/ioutil" + "net/mail" "strings" "time" @@ -15,6 +16,7 @@ func main() { emailer := contact.NewEmailer() as := args.NewArgSet() as.Append(args.STRING, "imap", "imap server:port", "imap.gmail.com:993") + as.Append(args.STRING, "pop3", "pop3 server:port", "") as.Append(args.INT, "n", "limit (<1 for inf)", 10) as.Append(args.STRING, "u", "username", emailer.From) as.Append(args.STRING, "p", "password", emailer.Password) @@ -23,11 +25,19 @@ func main() { } emailer.IMAP = as.Get("imap").GetString() + emailer.POP3 = as.Get("pop3").GetString() emailer.Limit = as.Get("n").GetInt() emailer.From = as.GetString("u") emailer.Password = as.GetString("p") - msgs, err := emailer.Read() + var msgs <-chan *mail.Message + var err error + if emailer.POP3 != "" { + msgs, err = emailer.ReadPOP3() + } else { + msgs, err = emailer.Read() + } + if err != nil { panic(err) }