libUnreadMail/unreadMail/unreadMail.go

39 lines
862 B
Go
Raw Normal View History

2017-08-05 18:42:14 +02:00
// Example program for the unreadMail library
package main
import (
"flag"
"fmt"
"git.gutmet.org/goutil"
2017-08-05 18:42:14 +02:00
"git.gutmet.org/libUnreadMail"
"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")
pwFilePtr := flag.String("pwfile", "", "password file for user")
2017-08-05 18:42:14 +02:00
flag.Parse()
passwd, err := goutil.ReadFile(*pwFilePtr)
if err != nil {
fmt.Fprintln(os.Stderr, err)
} 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
}
}