|
@@ -1,20 +1,25 @@
|
|
|
package main
|
|
package main
|
|
|
import(
|
|
import(
|
|
|
"crypto/tls"
|
|
"crypto/tls"
|
|
|
|
|
+ "strings"
|
|
|
"gopkg.in/gomail.v2"
|
|
"gopkg.in/gomail.v2"
|
|
|
"966.it/ini"
|
|
"966.it/ini"
|
|
|
"966.it/opt"
|
|
"966.it/opt"
|
|
|
- //"gopkg.in/ini.v1"
|
|
|
|
|
"fmt"
|
|
"fmt"
|
|
|
//"os"
|
|
//"os"
|
|
|
)
|
|
)
|
|
|
func main() {
|
|
func main() {
|
|
|
|
|
|
|
|
//var cfg *ini.File
|
|
//var cfg *ini.File
|
|
|
|
|
+ // var struttura optp.IniStru
|
|
|
|
|
+
|
|
|
|
|
+ struttura := optp.Start()
|
|
|
|
|
+ fmt.Println("parametri:",struttura)
|
|
|
|
|
+
|
|
|
|
|
+ iniFile := struttura.IniFile
|
|
|
|
|
|
|
|
- iniFile := optp.Start()
|
|
|
|
|
fmt.Println("parametro passato",iniFile)
|
|
fmt.Println("parametro passato",iniFile)
|
|
|
- inip.GetIni(iniFile)
|
|
|
|
|
|
|
+ inip.GetIni(*iniFile)
|
|
|
_ = inip.LoadIni()
|
|
_ = inip.LoadIni()
|
|
|
|
|
|
|
|
// sezione di prova per vedere cosa ritorna dal file
|
|
// sezione di prova per vedere cosa ritorna dal file
|
|
@@ -48,6 +53,20 @@ protocol := inip.GetMyKey("mail","protocol").String()
|
|
|
_subject := inip.GetMyKey("mail","_subject").String()
|
|
_subject := inip.GetMyKey("mail","_subject").String()
|
|
|
_body := inip.GetMyKey("mail","_text").String()
|
|
_body := inip.GetMyKey("mail","_text").String()
|
|
|
|
|
|
|
|
|
|
+// sostituisco alcuni valori con quelli passati da iniStru
|
|
|
|
|
+if len(*struttura.IniFrom) > 0 {
|
|
|
|
|
+ _from = *struttura.IniFrom
|
|
|
|
|
+}
|
|
|
|
|
+if len(*struttura.IniTo) > 0 {
|
|
|
|
|
+ _to = strings.Split(*struttura.IniTo,",")
|
|
|
|
|
+}
|
|
|
|
|
+if len(*struttura.IniSubject) > 0 {
|
|
|
|
|
+ _subject = *struttura.IniSubject
|
|
|
|
|
+}
|
|
|
|
|
+if len(*struttura.IniBody) > 0 {
|
|
|
|
|
+ _body = *struttura.IniBody
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
for _,tos := range _to {
|
|
for _,tos := range _to {
|
|
|
m := gomail.NewMessage()
|
|
m := gomail.NewMessage()
|
|
|
m.SetHeader("From",_from)
|
|
m.SetHeader("From",_from)
|