Merge pull request #34 from ekrgb/master

Extended configuration to allow to set the hostname of the smtp client.
This commit is contained in:
Michael de Wit 2019-11-09 12:31:42 +01:00 committed by GitHub
commit cac5229ecc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View file

@ -7,6 +7,8 @@ const (
DefaultOnlyRecipients = false
// DefaultSkipVerify controls wether to skip SSL verification for the SMTP server
DefaultSkipVerify = false
// DefaultClientHostname is the client hostname used in the HELO command sent to the SMTP server
DefaultClientHostname = "localhost"
)
// DefaultSubject is the default subject template to use for the email

View file

@ -84,6 +84,13 @@ func main() {
Usage: "attachment filename(s)",
EnvVar: "PLUGIN_ATTACHMENTS",
},
cli.StringFlag{
Name: "clienthostname",
Value: DefaultClientHostname,
Usage: "smtp client hostname",
EnvVar: "EMAIL_CLIENTHOSTNAME,PLUGIN_CLIENTHOSTNAME",
},
// Drone environment
// Repo
@ -381,6 +388,7 @@ func run(c *cli.Context) error {
Body: c.String("template.body"),
Attachment: c.String("attachment"),
Attachments: c.StringSlice("attachments"),
ClientHostname: c.String("clienthostname"),
},
}

View file

@ -91,6 +91,7 @@ type (
Body string
Attachment string
Attachments []string
ClientHostname string
}
Plugin struct {
@ -133,6 +134,7 @@ func (p Plugin) Exec() error {
if p.Config.SkipVerify {
dialer.TLSConfig = &tls.Config{InsecureSkipVerify: true}
}
dialer.LocalName = p.Config.ClientHostname
closer, err := dialer.Dial()
if err != nil {