|
|
@@ -1,6 +1,6 @@
|
|
|
package main
|
|
|
import(
|
|
|
- //"crypto/tls"
|
|
|
+ "crypto/tls"
|
|
|
"gopkg.in/gomail.v2"
|
|
|
"966.it/ini"
|
|
|
"966.it/opt"
|
|
|
@@ -45,7 +45,7 @@ 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()
|
|
|
|
|
|
@@ -54,12 +54,15 @@ for _,tos := range _to {
|
|
|
m.SetHeader("From",_from)
|
|
|
m.SetHeader("To",tos)
|
|
|
m.SetHeader("Subject",_subject)
|
|
|
- m.SetBody("Text/Text",_body)
|
|
|
+ m.SetBody("Text/plain",_body)
|
|
|
|
|
|
d := gomail.NewDialer(server,porta,username,password)
|
|
|
- d.SSL=true
|
|
|
|
|
|
- //d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
|
|
+ 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 {
|