From 096424ff3b76163350f42121ba0c0d8a58dc117e Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Wed, 20 Apr 2022 17:56:13 -0600 Subject: [PATCH] impl recv.go --- contact/email.go | 2 +- recv.go | 28 ++++++++++++++++++++++++++++ send.go | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 recv.go diff --git a/contact/email.go b/contact/email.go index 423484d..57194fb 100755 --- a/contact/email.go +++ b/contact/email.go @@ -33,7 +33,7 @@ func NewEmailer() *Emailer { return &Emailer{ From: envOr("FROM", "breellocaldev@gmail.com"), SMTP: envOr("SMTP", "smtp.gmail.com:465"), - Password: envOr("PASSWORD", "ML3WQRFSqe9rQ8qNkm"), + Password: envOr("PASSWORD", "lhnjijrvqaesiufp"), } } diff --git a/recv.go b/recv.go new file mode 100755 index 0000000..f12bae8 --- /dev/null +++ b/recv.go @@ -0,0 +1,28 @@ +package main + +import ( + "local/args" + "local/sandbox/contact/contact" + "log" +) + +func main() { + emailer := contact.NewEmailer() + as := args.NewArgSet() + as.Append(args.STRING, "imap", "imap server:port", "imap.gmail.com:993") + as.Append(args.INT, "n", "limit (<1 for inf)", 10) + if err := as.Parse(); err != nil { + panic(err) + } + + emailer.IMAP = as.Get("imap").GetString() + emailer.Limit = as.Get("n").GetInt() + + msgs, err := emailer.Read() + if err != nil { + panic(err) + } + for msg := range msgs { + log.Println(msg) + } +} diff --git a/send.go b/send.go index a890cca..427dcb1 100755 --- a/send.go +++ b/send.go @@ -18,7 +18,7 @@ func main() { if err := as.Parse(); err != nil { panic(err) } - emailer := &contact.Emailer{ + emailer = &contact.Emailer{ From: as.Get("from").GetString(), SMTP: as.Get("smtp").GetString(), POP3: as.Get("pop3").GetString(),