2017-08-05 18:42:14 +02:00
|
|
|
// Example program for the unreadMail library
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
2019-01-03 17:18:19 +01:00
|
|
|
"git.gutmet.org/goutil.git"
|
|
|
|
"git.gutmet.org/libUnreadMail.git"
|
2017-08-05 18:42:14 +02:00
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
serverPtr := flag.String("server", "", "server IP")
|
|
|
|
portPtr := flag.Int("port", 993, "server port")
|
|
|
|
certPtr := flag.String("cert", "", "PEM cert of server")
|
|
|
|
userPtr := flag.String("user", "", "user login name")
|
2017-09-08 14:38:00 +02:00
|
|
|
pwFilePtr := flag.String("pwfile", "", "password file for user")
|
2017-08-05 18:42:14 +02:00
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
2017-09-08 14:38:00 +02:00
|
|
|
passwd, err := goutil.ReadFile(*pwFilePtr)
|
|
|
|
|
|
|
|
if err != nil {
|
2017-08-14 18:22:50 +02:00
|
|
|
fmt.Fprintln(os.Stderr, err)
|
2017-09-08 14:38:00 +02:00
|
|
|
} 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")
|
|
|
|
}
|
2017-08-05 18:42:14 +02:00
|
|
|
}
|
|
|
|
}
|