8484730b82
I have switched the mail sending mechanism to gomail to get more power out of the sending method. Beside that I have added a flag to skip certificate verification. On top of that I have integrated the drone templating to make it possible to overwrite the email templates optionally. To be more compatible I have created a plaintext message format with the help of html2text as well.
59 lines
861 B
Go
59 lines
861 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/drone/drone-go/drone"
|
|
"github.com/drone/drone-go/plugin"
|
|
)
|
|
|
|
var (
|
|
buildDate string
|
|
)
|
|
|
|
func main() {
|
|
fmt.Printf("Drone Email Plugin built at %s\n", buildDate)
|
|
|
|
system := drone.System{}
|
|
repo := drone.Repo{}
|
|
build := drone.Build{}
|
|
vargs := Params{}
|
|
|
|
plugin.Param("system", &system)
|
|
plugin.Param("repo", &repo)
|
|
plugin.Param("build", &build)
|
|
plugin.Param("vargs", &vargs)
|
|
plugin.MustParse()
|
|
|
|
if len(vargs.Recipients) == 0 {
|
|
vargs.Recipients = []string{
|
|
build.Email,
|
|
}
|
|
}
|
|
|
|
if vargs.Subject == "" {
|
|
vargs.Subject = defaultSubject
|
|
}
|
|
|
|
if vargs.Template == "" {
|
|
vargs.Template = defaultTemplate
|
|
}
|
|
|
|
if vargs.Port == 0 {
|
|
vargs.Port = 587
|
|
}
|
|
|
|
err := Send(&Context{
|
|
System: system,
|
|
Repo: repo,
|
|
Build: build,
|
|
Vargs: vargs,
|
|
})
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|