package main import( "crypto/tls" "gopkg.in/gomail.v2" "966.it/ini" "966.it/opt" //"gopkg.in/ini.v1" "fmt" //"os" ) func main() { //var cfg *ini.File iniFile := optp.Start() fmt.Println("parametro passato",iniFile) inip.GetIni(iniFile) _ = inip.LoadIni() // sezione di prova per vedere cosa ritorna dal file fmt.Println(inip.GetMySection()) /* var err error mymail,err = cfg.GetSection("mail") if err != nil { fmt.Println("Errore nella lettura della sezione") fmt.Println(err) os.Exit(99) } var mymail *ini.Section keys := mymail.KeyStrings() for _,x := range keys { fmt.Println(x) } */ server := inip.GetMyKey("mail","server").String() porta,_ := inip.GetMyKey("mail","porta").Int() username := inip.GetMyKey("mail","username").String() password := inip.GetMyKey("mail","password").String() _from := inip.GetMyKey("mail","_from").String() _to := inip.GetMyKey("mail","_to").Strings(",") protocol := inip.GetMyKey("mail","protocol").String() _subject := inip.GetMyKey("mail","_subject").String() _body := inip.GetMyKey("mail","_text").String() for _,tos := range _to { m := gomail.NewMessage() m.SetHeader("From",_from) m.SetHeader("To",tos) m.SetHeader("Subject",_subject) m.SetBody("Text/plain",_body) d := gomail.NewDialer(server,porta,username,password) if protocol == "ssl" { d.SSL=true } else if protocol == "tls" { d.TLSConfig = &tls.Config{InsecureSkipVerify: true} } // Send the email to Bob, Cora and Dan. if err := d.DialAndSend(m); err != nil { panic(err) } } }