recv uses pop3 if provided
parent
48cb9bf32b
commit
6b04a324f3
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue