falcon mail provider模块的源码修改

              本文重点:falcon mail provider模块的源码修改

              1packagehttp23import(4"fmt"5"net"6"net/http"7"log"8"net/mail"9"net/smtp"10"crypto/tls"11"strings"121314"/open-falcon/mail-provider/config"15"/toolkits/web/param"16)1718funcconfigProcRoutes(){("/mail",func(,r*){21cfg:=()22token:=(r,"token","")!=token{(w,"noprivilege",)25return26}2728tos:=(r,"tos")29//("传入的tos:",tos)30subject:=(r,"subject")31content:=(r,"content")32tos=(tos,",",";",-1)33//("替换后的tos:",tos)34err:=SslMail(tos,subject,content)35iferr!=nil{(w,(),)37}else{(w,"success",)39}40})4142}4344//SSL/TLSEmail4546funcSslMail(tosstring,subjectstring,contentstring)error{474849cfg:=()5051from:={"",}52to:=tos53toaddr:=(tos,";")("toaddr:",toaddr)55subj:=subject56body:=content575859//Setupheaders60headers:=make(map[string]string)61headers["From"]=()62//headers["To"]=()63headers["To"]=to64headers["Subject"]=subj6566//Setupmessage67message:=""68fork,v:=rangeheaders{69message+=("%s:%s\r",k,v)70}71message+="\r"+body7273//ConnecttotheSMTPServer74servername:=,_,_:=(servername)7677auth:=("",,,host)7879//TLSconfig80tlsconfig:=&{81InsecureSkipVerify:true,82ServerName:host,83}8485//Hereisthekey,//forsmtpserversrunningon465thatrequireansslconnection87//fromtheverybeginning(nostarttls)88conn,err:=("tcp",servername,tlsconfig)89iferr!=nil{(err)91returnerr92}9394c,err:=(conn,host)95iferr!=nil{(err)97returnerr98}99100//Auth101iferr=(auth);err!=nil{(err)103returnerr104}105106//To&&From107iferr=();err!=nil{(err)109returnerr110}111112for_,addr:=rangetoaddr{113iferr=(addr);err!=nil{(err)115returnerr116}117}118119//Data120w,err:=()121iferr!=nil{(err)123returnerr124}125126_,err=([]byte(message))127iferr!=nil{(err)129returnerr130}131132err=()133iferr!=nil{(err)135returnerr136}()138returnnil139140}。