libUnreadMail/unreadMail/unreadMail.go
2019-01-03 17:18:19 +01:00

39 lines
870 B
Go

// Example program for the unreadMail library
package main
import (
"flag"
"fmt"
"git.gutmet.org/goutil.git"
"git.gutmet.org/libUnreadMail.git"
"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")
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")
}
}
}