diff --git a/unreadMail/unreadMail.go b/unreadMail/unreadMail.go index 379d6c5..9100647 100644 --- a/unreadMail/unreadMail.go +++ b/unreadMail/unreadMail.go @@ -5,6 +5,7 @@ package main import ( "flag" "fmt" + "git.gutmet.org/goutil" "git.gutmet.org/libUnreadMail" "os" ) @@ -14,17 +15,24 @@ func main() { portPtr := flag.Int("port", 993, "server port") certPtr := flag.String("cert", "", "PEM cert of server") userPtr := flag.String("user", "", "user login name") - passwdPtr := flag.String("passwd", "", "password for user") + pwFilePtr := flag.String("pwfile", "", "password file for user") flag.Parse() - par := &unreadMail.Parameters{*serverPtr, *portPtr, *certPtr, *userPtr, *passwdPtr} - mails, errs := unreadMail.FetchPlaintext(par) - for _, err := range errs { + passwd, err := goutil.ReadFile(*pwFilePtr) + + if err != nil { fmt.Fprintln(os.Stderr, err) - } - for _, mail := range mails { - fmt.Println(mail) - fmt.Println("\n=*=*=*=*=*=*=*=*=\n") + } else { + par := &unreadMail.Parameters{*serverPtr, *portPtr, *certPtr, *userPtr, passwd} + + mails, errs := unreadMail.FetchPlaintext(par) + for _, err := range errs { + fmt.Fprintln(os.Stderr, err) + } + for _, mail := range mails { + fmt.Println(mail) + fmt.Println("\n=*=*=*=*=*=*=*=*=\n") + } } }