recv uses pop3 if provided
parent
48cb9bf32b
commit
6b04a324f3
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/mail"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -15,6 +16,7 @@ func main() {
|
||||||
emailer := contact.NewEmailer()
|
emailer := contact.NewEmailer()
|
||||||
as := args.NewArgSet()
|
as := args.NewArgSet()
|
||||||
as.Append(args.STRING, "imap", "imap server:port", "imap.gmail.com:993")
|
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.INT, "n", "limit (<1 for inf)", 10)
|
||||||
as.Append(args.STRING, "u", "username", emailer.From)
|
as.Append(args.STRING, "u", "username", emailer.From)
|
||||||
as.Append(args.STRING, "p", "password", emailer.Password)
|
as.Append(args.STRING, "p", "password", emailer.Password)
|
||||||
|
|
@ -23,11 +25,19 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
emailer.IMAP = as.Get("imap").GetString()
|
emailer.IMAP = as.Get("imap").GetString()
|
||||||
|
emailer.POP3 = as.Get("pop3").GetString()
|
||||||
emailer.Limit = as.Get("n").GetInt()
|
emailer.Limit = as.Get("n").GetInt()
|
||||||
emailer.From = as.GetString("u")
|
emailer.From = as.GetString("u")
|
||||||
emailer.Password = as.GetString("p")
|
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue